user4427637
user4427637

Reputation:

Calling activity from Broadcast receiver

I want call another activity from BroadcastReceiver, but this code below is not calling the activity. please help me out to find appropriate answer.

public class MyBroadcastReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        Intent newIntent = new Intent("com.example.alaram.MESG");
        context.startService(newIntent);

    }
}

Upvotes: 2

Views: 174

Answers (1)

Sofi Software LLC
Sofi Software LLC

Reputation: 3939

The call to startService() starts a Service, not an Activity... as the name suggests.

Try:

    Intent intent = new Intent(context, YourActivity.class);
    context.startActivity(intent);

Upvotes: 1

Related Questions