I need to open a new lock screen while opening the other app... I have write service ... but which is not working out side of my app..
public int onStartCommand(Intent intent, int flags, int startId) {
Toast.makeText(this, "Service Started", Toast.LENGTH_LONG).show();
ActivityManager mActivityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
List<ActivityManager.RunningTaskInfo> RunningTask = mActivityManager.getRunningTasks(1);
ActivityManager.RunningTaskInfo ar = RunningTask.get(0);
String activityOnTop=ar.topActivity.getClassName();
if(activityOnTop!=null)
{
Toast.makeText(this,"activityOnTop"+""+activityOnTop,Toast.LENGTH_LONG).show();
{
Intent lockIntent = new Intent(this, LockScreen.class);
lockIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
this.startActivity(lockIntent);
}
}
return START_STICKY;
}