Reputation: 1
Just wondering if its possible to launch an install application from a background service. I have the packagename as well.
Upvotes: 0
Views: 357
Reputation: 3192
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
Upvotes: 0
Reputation: 583
Intent intent= getPackageManager().getLaunchIntentForPackage("com.example.package_name");
startActivity( intent);
For more information you can see package manager and getLaunchIntentForPackage
Upvotes: 0
Reputation: 1586
An installed application can be invoked using PackageManager class
startActivity(BackgroundService.this.getPackageManager()
.getLaunchIntentForPackage(packageName)
.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
Upvotes: 2