Just wondering if its possible to launch an install application from a background service. I have the packagename as well.
An installed application can be invoked using PackageManager class
startActivity(BackgroundService.this.getPackageManager()
.getLaunchIntentForPackage(packageName)
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
是的,您可以从服务启动活动。
Intent intent= getPackageManager().getLaunchIntentForPackage("com.example.package_name");
startActivity( intent);
For more information you can see package manager and getLaunchIntentForPackage
yes you can launch an activity from a service. use this code this is worked for me
Intent mIntent = new Intent(getApplicationContext(), YourActivity.class);
mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getApplicationContext().startActivity(mIntent);
don't forget to called mIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
otherwise its gives error
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.