Private void launch (Context Context, String packageName) {
//alipay packageName: "com. Eg. Android. AlipayGphone"
//cool dog music packageName: "com. Kugou. Android"
Intent Intent=context. GetPackageManager (). GetLaunchIntentForPackage (packageName);
If (intent==null) {
The d (" launcheee ", "launch: intent null");
return;
}
Intent. AddFlags (intent. FLAG_ACTIVITY_NEW_TASK);
The d (" launcheee ", "launch: intent:" + intent);
The context. StartActivity (intent);
}
Call this method in the Service start pay treasure, cool dog music APP, such as the first call to this method can normal boot, shut down after start the APP, follow-up call this method that will not be able to start again,
Close to press in the top right corner of the x is fully closed, not press the back key
There is a Warning, this is the second time when starting pay treasure of a Warning
Forbiden launch for the activity: ActivityRecord {a6f7baf u0 com. Eg. Android. AlipayGphone/. AlipayLogin t - 1}
Note: the test on the rails in the Activity, and only in the Service for the first time successfully opened, there are exceptions of the APP (such as WeChat)
Testing machine: huawei honor V9
Test the Android version: 8.0
CodePudding user response:
How did not answer, I also the same problem,