@ RivieeaKidによるhtml解析ソリューションが機能する中で、これはより耐久性が高く、正しいソリューションかもしれないことがわかりました。リダイレクトを避けるには、「https」プレフィックス(プレーンな「http」ではなく)を使用してください。
/**
* 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
*/
private boolean availableOnGooglePlay(final String packageName)
throws IOException
{
final URL url = new URL("https://play.google.com/store/apps/details?id=" + packageName);
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
httpURLConnection.setRequestMethod("GET");
httpURLConnection.connect();
final int responseCode = httpURLConnection.getResponseCode();
Log.d(TAG, "responseCode for " + packageName + ": " + responseCode);
if(responseCode == HttpURLConnection.HTTP_OK) // code 200
{
return true;
}
else // this will be HttpURLConnection.HTTP_NOT_FOUND or code 404 if the package is not found
{
return false;
}
}
Googleマーケットとのライセンス契約の細かいところをお読みください。これは違反の可能性があります。 – JPM