Check If App Available On Android Market
Given an Android application's id/package name, how can I check programatically if the application is available on the Android Market? For example: com.rovio.angrybirds is availabl
Solution 1:
You could try to open the details page for the app - https://market.android.com/details?id=com.rovio.angrybirds.
If the app doesn't exist, you get this:
It's perhaps not ideal, but you should be able to parse the returned HTML to determine that the app doesn't exist.
Solution 2:
Given an Android application's id/package name, how can I check programatically if the application is available on the Android Market?
There is no documented and supported means to do this.
Solution 3:
While the html parsing solution by @RivieeaKid works, I found that this might be a more durable and correct solution. Please make sure to use the 'https' prefix (not plain 'http') to avoid redirects.
/**
* Checks if an app with the specified package name is available on Google Play.
* Must be invoked from a separate thread in Android.
*
* @param packageName the name of package, e.g. "com.domain.random_app"
* @return {@code true} if available, {@code false} otherwise
* @throws IOException if a network exception occurs
*/privatebooleanavailableOnGooglePlay(final String packageName)throws IOException
{
finalURLurl=newURL("https://play.google.com/store/apps/details?id=" + packageName);
HttpURLConnectionhttpURLConnection= (HttpURLConnection) url.openConnection();
httpURLConnection.setRequestMethod("GET");
httpURLConnection.connect();
finalintresponseCode= httpURLConnection.getResponseCode();
Log.d(TAG, "responseCode for " + packageName + ": " + responseCode);
if(responseCode == HttpURLConnection.HTTP_OK) // code 200
{
returntrue;
}
else// this will be HttpURLConnection.HTTP_NOT_FOUND or code 404 if the package is not found
{
returnfalse;
}
}
Post a Comment for "Check If App Available On Android Market"