Somyong Ri
Somyong Ri

Reputation: 95

StartActivity in android broadcast receiver

I registered receiving SMS broadcast in manifest.xml. How can I start new Activity in receive() method of the broadcast. is there any flags of Intent to set or anything?

Upvotes: 3

Views: 5333

Answers (1)

RajaReddy PolamReddy
RajaReddy PolamReddy

Reputation: 22493

use FLAG_ACTIVITY_NEW_TASK like this

@Override
public void onReceive(Context context, Intent intent)   {

    Intent i = new Intent(context, AlarmDialog.class);
    i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(i);    
}

Upvotes: 11

Related Questions