List of utility methods to do APK Installation Check
boolean | isAppInstalled(Context ctx, String uri) is App Installed PackageManager pm = ctx.getPackageManager(); boolean installed = false; try { pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES); installed = true; } catch (PackageManager.NameNotFoundException e) { installed = false; return installed; |
boolean | isApkInstalled(Context context, String packageName) is Apk Installed PackageInfo packageInfo = null; try { packageInfo = context.getPackageManager().getPackageInfo( packageName, PackageManager.GET_ACTIVITIES); } catch (NameNotFoundException e) { packageInfo = null; e.printStackTrace(); if (packageInfo == null) { return false; } else { Log.e(TAG, packageInfo.toString()); return true; |
void | installApk(Context context, File file) install Apk Intent intent = new Intent(); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setAction(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive"); context.startActivity(intent); |
void | installApk(Context context, File file) install Apk Intent intent = new Intent(); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setAction(android.content.Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive"); context.startActivity(intent); |
void | uninstallApk(Context context, String packageName) uninstall Apk Intent intent = new Intent(Intent.ACTION_DELETE); Uri packageURI = Uri.parse("package:" + packageName); intent.setData(packageURI); context.startActivity(intent); |
boolean | verifySampleSetup(Activity activity, int... resIds) For use in sample code only. StringBuilder problems = new StringBuilder(); boolean problemFound = false; problems.append("The following set up problems were found:\n\n"); if (activity.getPackageName() .startsWith("com.google.example.games")) { problemFound = true; problems.append( "- Package name cannot be com.google.*. You need to change the " ... |
void | installWatchapp(final Activity parent, final String pbwFilename, final String appstoreUid) Let use choose install source for 2.0 use AlertDialog.Builder dialog = new AlertDialog.Builder(parent); dialog.setTitle("Choose Install Method"); dialog.setMessage("Choose 'Pebble Appstore' if you are using 2.0 BETA 9+, else choose 'Local .pbw'."); dialog.setPositiveButton("Local .pbw", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(parent, ... |