Java Code Examples for android.content.Intent#ACTION_UNINSTALL_PACKAGE
The following examples show how to use
android.content.Intent#ACTION_UNINSTALL_PACKAGE .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DummyActivity.java From Shelter with Do What The F*ck You Want To Public License | 6 votes |
private void actionUninstallPackage() { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { actionUninstallPackageQ(); return; } Uri uri = Uri.fromParts("package", getIntent().getStringExtra("package"), null); Intent intent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE, uri); intent.putExtra(Intent.EXTRA_RETURN_RESULT, true); // Currently, Install & Uninstall share the same logic // after starting the system PackageInstaller // because the only thing to do is to call the callback // with the result code. // If ANY separate logic is added for any of them, // the request code should be separated. startActivityForResult(intent, REQUEST_INSTALL_PACKAGE); }
Example 2
Source File: MainActivity.java From LaunchTime with GNU General Public License v3.0 | 5 votes |
private void launchUninstallIntent(AppLauncher app, ViewGroup parent, View launcher) { if (mChildLock) return; mDragDropSource = parent; mBeingUninstalled = launcher; Log.d(TAG, "Uninstalling " + app.getPackageName()); Uri packageUri = Uri.parse("package:" + app.getPackageName()); Intent uninstallIntent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE, packageUri); uninstallIntent.putExtra(Intent.EXTRA_RETURN_RESULT, true); startActivityForResult(uninstallIntent, UNINSTALL_RESULT); }
Example 3
Source File: PreferencesActivity.java From always-on-amoled with GNU General Public License v3.0 | 5 votes |
public static void uninstall(Context context, Prefs prefs) { try { ComponentName devAdminReceiver = new ComponentName(context, DAReceiver.class); DevicePolicyManager dpm = (DevicePolicyManager) context.getSystemService(Context.DEVICE_POLICY_SERVICE); dpm.removeActiveAdmin(devAdminReceiver); if (prefs.proximityToLock && Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP && !Shell.SU.available()) prefs.setBool(Prefs.KEYS.PROXIMITY_TO_LOCK.toString(), false); } catch (Exception ignored) { } Uri packageUri = Uri.parse("package:" + context.getPackageName()); Intent uninstallIntent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE, packageUri); uninstallIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(uninstallIntent); }
Example 4
Source File: MainActivity.java From DebugPurge with MIT License | 5 votes |
public static Intent getUninstallIntent(String packageName) { final Uri packageURI = Uri.parse("package:" + packageName); final Intent intent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE, packageURI); intent.putExtra("android.intent.extra.UNINSTALL_ALL_USERS", true); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); return intent; }
Example 5
Source File: AppDetailsActivity.java From KAM with GNU General Public License v3.0 | 5 votes |
@OnClick(R.id.delete) public void onDelete() { Intent intent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE); intent.setData(Uri.parse("package:" + appsModel.getPackageName())); intent.putExtra(Intent.EXTRA_RETURN_RESULT, true); startActivityForResult(intent, APP_RESULT); fabtoolbar.slideOutFab(); }
Example 6
Source File: InstallApk.java From codeexamples-android with Eclipse Public License 1.0 | 5 votes |
public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE); intent.setData(Uri.parse( "package:com.example.android.helloactivity")); intent.putExtra(Intent.EXTRA_RETURN_RESULT, true); startActivityForResult(intent, REQUEST_UNINSTALL); }
Example 7
Source File: PackageInstallerService.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
@Override public void uninstall(VersionedPackage versionedPackage, String callerPackageName, int flags, IntentSender statusReceiver, int userId) throws RemoteException { final int callingUid = Binder.getCallingUid(); mPermissionManager.enforceCrossUserPermission(callingUid, userId, true, true, "uninstall"); if ((callingUid != Process.SHELL_UID) && (callingUid != Process.ROOT_UID)) { mAppOps.checkPackage(callingUid, callerPackageName); } // Check whether the caller is device owner or affiliated profile owner, in which case we do // it silently. final int callingUserId = UserHandle.getUserId(callingUid); DevicePolicyManagerInternal dpmi = LocalServices.getService(DevicePolicyManagerInternal.class); final boolean isDeviceOwnerOrAffiliatedProfileOwner = dpmi != null && dpmi.isActiveAdminWithPolicy(callingUid, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER) && dpmi.isUserAffiliatedWithDevice(callingUserId); final PackageDeleteObserverAdapter adapter = new PackageDeleteObserverAdapter(mContext, statusReceiver, versionedPackage.getPackageName(), isDeviceOwnerOrAffiliatedProfileOwner, userId); if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.DELETE_PACKAGES) == PackageManager.PERMISSION_GRANTED) { // Sweet, call straight through! mPm.deletePackageVersioned(versionedPackage, adapter.getBinder(), userId, flags); } else if (isDeviceOwnerOrAffiliatedProfileOwner) { // Allow the device owner and affiliated profile owner to silently delete packages // Need to clear the calling identity to get DELETE_PACKAGES permission long ident = Binder.clearCallingIdentity(); try { mPm.deletePackageVersioned(versionedPackage, adapter.getBinder(), userId, flags); } finally { Binder.restoreCallingIdentity(ident); } } else { ApplicationInfo appInfo = mPm.getApplicationInfo(callerPackageName, 0, userId); if (appInfo.targetSdkVersion >= Build.VERSION_CODES.P) { mContext.enforceCallingOrSelfPermission(Manifest.permission.REQUEST_DELETE_PACKAGES, null); } // Take a short detour to confirm with user final Intent intent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE); intent.setData(Uri.fromParts("package", versionedPackage.getPackageName(), null)); intent.putExtra(PackageInstaller.EXTRA_CALLBACK, adapter.getBinder().asBinder()); adapter.onUserActionRequired(intent); } }
Example 8
Source File: LauncherActivity.java From Last-Launcher with GNU General Public License v3.0 | 4 votes |
private void uninstallApp(String activityName) { Intent intent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE); intent.setData(Uri.parse("package:" + activityName.split("/")[0])); intent.putExtra(Intent.EXTRA_RETURN_RESULT, true); startActivityForResult(intent, 97); }
Example 9
Source File: BackupManageAppFragment.java From SAI with GNU General Public License v3.0 | 4 votes |
@Override public void deleteApp(BackupApp backupApp) { Intent intent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE); intent.setData(new Uri.Builder().scheme("package").opaquePart(backupApp.packageMeta().packageName).build()); startActivity(intent); }
Example 10
Source File: DefaultMiscActions.java From under-the-hood with Apache License 2.0 | 4 votes |
/** * Raw intent to open app's uninstall prompt */ public static Intent getAppUninstallIntent(Context ctx) { Intent intent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE); intent.setData(Uri.parse("package:" + ctx.getPackageName())); return intent; }
Example 11
Source File: NavigationManager.java From AppPlus with MIT License | 4 votes |
public static void uninstallApp(Activity activity, String packageName) { Intent intent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE); intent.setData(Uri.parse("package:" + packageName)); intent.putExtra(Intent.EXTRA_RETURN_RESULT, true); activity.startActivityForResult(intent, UNINSTALL_REQUEST_CODE); }
Example 12
Source File: InstallApk.java From codeexamples-android with Eclipse Public License 1.0 | 4 votes |
public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE); intent.setData(Uri.parse( "package:com.example.android.helloactivity")); startActivity(intent); }
Example 13
Source File: MainActivity.java From android-appops-launcher with Do What The F*ck You Want To Public License | 4 votes |
private void uninstallAppOps() { Toast.makeText(this, R.string.error_msg, Toast.LENGTH_LONG).show(); Uri uri = Uri.parse("package:" + getPackageName()); Intent intent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE, uri); startActivity(intent); }