What is the easiest way to see if a user has a specific app in the Android Market, in my case Flash Player. If they don't have it I want to be able to take them to the Market to download it before continuing on with the app. Thanks.
Asked
Active
Viewed 307 times
0
-
can the specific app be the most used app.? – visista Jul 19 '11 at 15:32
-
explain what do u mean by specific app – visista Jul 19 '11 at 15:49
-
I want to check if they have Flash Player installed because my app uses flash player and if they don't I want to take them to the Market to download it so they aren't always asking why they can't preview music. – Nick Nelson Jul 19 '11 at 15:51
2 Answers
5
Here is a similar question about checking for Flash Player.
The relevant code (taken from Lior's answer) is this:
Intent intent = new Intent();
intent.setComponent(new ComponentName("com.adobe.flashplayer", "com.adobe.flashplayer.FlashExpandableFileChooser"));
PackageManager pm = getPackageManager();
List<ResolveInfo> activities = pm.queryIntentActivities(intent, 0);
if (activities != null && activities.size() > 0)
{
Toast.makeText(this, "Flash is installed!", Toast.LENGTH_LONG).show();
}
else
{
Intent flashIntent = new Intent(Intent.ACTION_VIEW,Uri.parse("https://market.android.com/details?id=com.adobe.flashplayer"));
startActivity(flashIntent);
}
-
So does that go in the onCreate method then? And I do not see an option to take them to the Market to install flash. Thank you for a start though. – Nick Nelson Jul 19 '11 at 15:46
-
Stack overflow posts should only have one question per post. If you want to know how to go to the market, that's a separate question - though one that has already been answered many times - you should search for the answers for that, as if you posted the question again it would be closed as a duplicate. Also, there are severe limitations in what you can do in the onCreate() method. – Chris Stratton Jul 19 '11 at 16:03
-
Sure, you can put it in onCreate(). To open the Market, just use a second Intent. I've added the appropriate code to open the market if Flash Player isn't found. – theisenp Jul 19 '11 at 16:05
-
Thanks. That should work. Instead of saying flash is installed, what would I include to just continue on with the app as if it didn't even check because most people have flash and that will be annoying. – Nick Nelson Jul 19 '11 at 16:18
-
If you don't want the app to do anything, then don't include that line. Just leave the body of the if statement blank. The Toast is purely cosmetic and the code is functionally the same without it. If you want, you can change your if-else structure to test for if(activities == null || activities.size() == 0) { //flashIntent code } and then eliminate the else statement. – theisenp Jul 19 '11 at 17:13
0
I know this has been answered but here is how I implemented something similar:
Intent intent = getActivity().getPackageManager().getLaunchIntentForPackage("com.package.address");
if (intent != null) {
// start the activity
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
} else {
// bring user to the market
// or let them choose an app?
intent = new Intent(Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setData(Uri.parse("market://details?id="+"com.package.address"));
startActivity(intent);
}

Jared Burrows
- 54,294
- 25
- 151
- 185