Startactivity inside Broadcastreceiver

Asked

Viewed 73 times

0

I want to go to another Victoria when I enter onReceive of my receiver, but always stops working on startActivity, the code I’m making is like this:

@Override
public void onReceive(Context context, Intent intent) {
    Toast.makeText(context, "Hora de ir", Toast.LENGTH_LONG).show();
    Intent i = new Intent(context, MyAlarmService.class);
    context.startActivity(i);
}
  • It may be a stupid question, but this one MyAlarmService is a Service? Why not start a Service in this way...

  • Qual a Exception?

  • is a normal class, I just put service by putting

  • Runtimeexception, and Activitynotfoundexception, the manifest being there

  • Did you put the package correctly? Or did you put it relative to the manifest package? Try to put the absolute path of Activity to see if the same problem happens.

  • just needed to add a flag FLAG_ACTIVITY_NEW_TASK.

Show 1 more comment

1 answer

1


Required to add FLAG_ACTIVITY_NEW_TASK.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.