This code works perfectly in the Activity Class, but if I move this code to Common (non Activity) class I'm getting this error:
Calling startActivity() from outside of an Activity context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?
Here is the code:
public static void emailIntend(Context context) {
Intent emailIntent = new Intent(Intent.ACTION_SENDTO, null);
emailIntent.putExtra(Intent.EXTRA_SUBJECT, context.getString(R.string.string_email_send_feedback_subject));
String[] receipients = new String[1];
receipients[0] = context.getString(R.string.string_email);
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, receipients);
emailIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(Intent.createChooser(emailIntent, "Send email to the developer..."));
}
And this is how I am calling from the Activity:
Common.emailIntend( getApplicationContext() );
I tried replacing getApplicationContext()
with this
, but no help.
Kindly, tell me if I am doing something not correct.