1

I am Launching an activity from the service. I am acquiring the partial wake lock before the service is started.

PowerManager mgr = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
lockStatic=mgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, LOCK_NAME_STATIC);
lockStatic.setReferenceCounted(true);

I am starting the activity from service like this :

Intent intent = new Intent(mContext, NotificationActivity.class);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);

In My Activity class i am adding flags to display activity when screen locked like this :

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
    /*Code to open a Dialog*/
}

When i Debug all the code works fine. Activity is called successfully. But if the screen is locked (There is no secure lock keyguard) the phone screen doesn't displays the activity. I have to manually unlock the phone and then can see the activity from running applications list.

isumit
  • 2,313
  • 4
  • 23
  • 28

1 Answers1

1

As described here you must also set FLAG_FULLSCREEN for your activity

nnesterov
  • 1,232
  • 1
  • 10
  • 27
  • adding FLAG_FULLSCREEN doesn't help. still not working – isumit Jul 11 '14 at 09:09
  • Along with the flags setting **android:theme="@android:style/Theme.NoTitleBar.Fullscreen"** for the activity in Manifest file made the activity visible above keyguard. – isumit Sep 02 '14 at 10:52