Note that there are some explanatory texts on larger screens.

plurals
  1. POCheck if application is installed - Android
    primarykey
    data
    text
    <p>I'm trying to install apps from Google Play. I can understand that on opening the Google Play store URL, it opens the Google Play and when I press the back button, the activity resumes.</p> <pre><code>Intent marketIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(appURL)); marketIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); startActivity(marketIntent); </code></pre> <p>When I went back to the activity, I tried calling this <code>onResume()</code> to check if the app is installed, but I receive an error:</p> <pre><code>@Override protected void onResume() { super.onResume(); boolean installed = false; while (!installed) { installed = appInstalledOrNot(APPPACKAGE); if (installed) { Toast.makeText(this, "App installed", Toast.LENGTH_SHORT).show(); } } } private boolean appInstalledOrNot(String uri) { PackageManager pm = getPackageManager(); boolean app_installed = false; try { pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES); app_installed = true; } catch (PackageManager.NameNotFoundException e) { app_installed = false; } return app_installed ; } </code></pre> <p>The error is as follows:</p> <blockquote> <p>E/AndroidRuntime(796): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.appinstaller/com.example.appinstaller.MainActivity}: android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=market://details?id=com.package.name flg=0x40080000 }</p> </blockquote> <p>I guess the activity is <code>onPause()</code>. Is there a better way to implement it? I'm trying to check if the app has finished installing.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload