Search code examples
androidandroid-serviceandroid-service-binding

Android _ redirect from a service class to another Activity?


Can I redirect from a service class to another Activity ?

I need that when my process finish in service redirect me to another activity .


Solution

  • Did you try like this ?

     Intent in=new Intent().setClass(MyAlarmService.this,Reminder.class);
    in.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            startActivity(in);
    

    Edit :

    If you are using BroadcastReceiver try this

    Intent iAlarm = new Intent( mcontext, YourActivity.class );
                         iAlarm.addFlags(Intent.FLAG_FROM_BACKGROUND); 
                         iAlarm.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
    mcontext.startActivity(iAlarm);