I am trying to install applications from Google Play. I can understand that when I open the URL of the Google Play store, Google Play opens, and when I click the back button, activity resumes.
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);
When I returned to this activity, I tried calling this onResume() to check if the application is installed, but I get an error message:
@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 ; }
The error is as follows:
E / AndroidRuntime (796): java.lang.RuntimeException: cannot start Events ComponentInfo {com.example.appinstaller / com.example.appinstaller.MainActivity}: android.content.ActivityNotFoundException: No activity found for operation Intent {act = android. intent.action.VIEW dat = market: // details? id = com.package.name flg = 0x40080000}
I assume the activity is onPause() . Is there a better way to implement it? I am trying to check if the application is completed.
android android-intent google-play
Siddharthan Asokan Sep 11 '13 at 22:15 2013-09-11 22:15
source share