How to start an Intent if context is not Activity Context but Application Context?

Here is sample code how to call another activity using context...

Up vote 0 down vote favorite share g+ share fb share tw.

I'm trying to start an activity from a class that extends BroadcastReceiver. Public void onReceive(Context context, Intent intent) { the problem is that parameter context is the Application context and not an Activity context. Is there a way start an intent using the Application context?

Thanks! Android application android-intent context link|improve this question asked Feb 11 at 2:57Marco Matarazzi13912 89% accept rate.

Here is sample code how to call another activity using context... Set flag as per your requirement... public void onReceive(Context context, Intent intent) { Intent startActivity = new Intent(); startActivity. SetClass(context, xxx. Class); startActivity.

SetAction(xxx.class.getName()); startActivity. SetFlags( Intent. FLAG_ACTIVITY_NEW_TASK | Intent.

FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); context. StartActivity(startActivity); }.

Thanks! It's working ok now :) – Marco Matarazzi Feb 13 at 18:17.

Yup, simply use the context and call the startActivity() method from that context.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions