简体   繁体   中英

Start android app from sleeping device (not own activity)?

I'd like to start an app from a sleeping device.

First i do a wakelock to wakeup screen. But i cant get the device to unlock?

I know i can start my own activity with something like:

this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN |
        WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | 

but as i'd like to start an 3rd party app app i cant use getWindow() :

mContext.startActivity(mContext.getPackageManager().getLaunchIntentForPackage("com.sec.android.app.xy"));

Is there any way to set the flags before starting the activity?

If you know the third party's package and launcher activity names , this code should work (mPackage and mActivityName are those strings):

Intent LaunchIntent = new Intent();
LaunchIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
LaunchIntent.setClassName(mPackage, mPackage + "." + mActivityName);
mContext.startActivity(LaunchIntent);

and mContext is the original application context (which you can instantiate as Context mContext = this.getApplicationContext(); ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM