Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call An activity class from a service class

Tags:

android

In my app there is a service class and need to call an activity class from that service class,but it each time while calling the activity class its show me a message that application is not responding ,and below is my code..

public class MyAlarmService_Movie extends Service {
    @Override
    public void onCreate() {
        super.onStart(intent, startId);
        Intent in=new Intent().setClass(MyAlarmService.this,Reminder.class);
        startActivity(in);
    }
}
like image 438
user595226 Avatar asked Dec 08 '25 06:12

user595226


1 Answers

Give in.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); before starting the intent.

like image 109
Anju Avatar answered Dec 09 '25 19:12

Anju