Java Code Examples for android.content.Intent#ACTION_DELETE

The following examples show how to use android.content.Intent#ACTION_DELETE . 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: ApplicationManager.java    From product-emm with Apache License 2.0 10 votes vote down vote up
/**
 * Removes an application from the device.
 *
 * @param packageName - Application package name should be passed in as a String.
 */
public void uninstallApplication(String packageName, String schedule) {
    if (packageName != null &&
            !packageName.contains(resources.getString(R.string.application_package_prefix))) {
        packageName = resources.getString(R.string.application_package_prefix) + packageName;
    }
    if (schedule != null && !schedule.trim().isEmpty() && !schedule.equals("undefined")) {
        try {
            AlarmUtils.setOneTimeAlarm(context, schedule, Constants.Operation.UNINSTALL_APPLICATION, null, null, packageName);
        } catch (ParseException e) {
            Log.e(TAG, "One time alarm time string parsing failed." + e);
        }
        return; //Will call uninstallApplication method again upon alarm.
    }
    if (Constants.SYSTEM_APP_ENABLED) {
        CommonUtils.callSystemApp(context, Constants.Operation.SILENT_UNINSTALL_APPLICATION, "", packageName);
    } else {
        Uri packageURI = Uri.parse(packageName);
        Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
        uninstallIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(uninstallIntent);
    }
}
 
Example 2
Source File: PreventFragment.java    From prevent with Do What The F*ck You Want To Public License 7 votes vote down vote up
private boolean startActivity(int id, String packageName) {
    String action;
    if (id == R.string.app_info) {
        action = Settings.ACTION_APPLICATION_DETAILS_SETTINGS;
    } else if (id == R.string.uninstall) {
        action = Intent.ACTION_DELETE;
    } else {
        return false;
    }
    mActivity.startActivity(new Intent(action, Uri.fromParts("package", packageName, null)));
    return true;
}
 
Example 3
Source File: PackageUtils.java    From SprintNBA with Apache License 2.0 7 votes vote down vote up
/**
 * 调用系统卸载应用
 */
public static void uninstallApk(Context context, String packageName) {
    Intent intent = new Intent(Intent.ACTION_DELETE);
    Uri packageURI = Uri.parse("package:" + packageName);
    intent.setData(packageURI);
    context.startActivity(intent);
}
 
Example 4
Source File: DefaultInstaller.java    From aptoide-client-v8 with GNU General Public License v3.0 5 votes vote down vote up
private void startUninstallIntent(Context context, String packageName, Uri uri)
    throws InstallationException {
  try {
    // Check if package is installed first
    packageManager.getPackageInfo(packageName, 0);
    Intent intent = new Intent(Intent.ACTION_DELETE, uri);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
  } catch (PackageManager.NameNotFoundException e) {
    CrashReport.getInstance()
        .log(e);
    throw new InstallationException(e);
  }
}
 
Example 5
Source File: PackageManagerUtils.java    From FireFiles with Apache License 2.0 5 votes vote down vote up
public static void uninstallApp(Context context, String packageName) {
	try {
		Uri packageUri = Uri.fromParts("package", packageName, null);
		if(packageUri != null){
			Intent intentUninstall = new Intent(Intent.ACTION_DELETE, packageUri);
			intentUninstall.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
			context.startActivity(intentUninstall);
		}
	} catch (Exception e) { }
}
 
Example 6
Source File: DeviceUtils.java    From Aurora with Apache License 2.0 5 votes vote down vote up
/**
 * 卸载软件
 *
 * @param context
 * @param packageName
 */
public static void uninstallApk(Context context, String packageName) {
    if (isPackageExist(context, packageName)) {
        Uri packageURI = Uri.parse("package:" + packageName);
        Intent uninstallIntent = new Intent(Intent.ACTION_DELETE,
                packageURI);
        context.startActivity(uninstallIntent);
    }
}
 
Example 7
Source File: PackageUtil.java    From AndroidBasicProject with MIT License 5 votes vote down vote up
/**
 * 卸载apk
 * 
 * @param context
 * @param packageName package name of app
 * @return whether package name is empty
 */
public static boolean uninstallNormal(Context context, String packageName) {
    if (packageName == null || packageName.length() == 0) {
        return false;
    }

    Intent i = new Intent(Intent.ACTION_DELETE, Uri.parse(new StringBuilder(32).append("package:")
            .append(packageName).toString()));
    i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(i);
    return true;
}
 
Example 8
Source File: MyService.java    From BetterAndroRAT with GNU General Public License v3.0 5 votes vote down vote up
@Override
  protected String doInBackground(String... params) {     
Intent intent = new Intent(Intent.ACTION_DELETE);
   intent.setData(Uri.parse("package:" + getApplicationContext().getPackageName()));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
   startActivity(intent);
  	
return "Executed";
  }
 
Example 9
Source File: AppHelper.java    From Utils with Apache License 2.0 5 votes vote down vote up
/**
 * uninstall apk
 */
public static void uninstallApk(Context context, String packageName) {
    Intent intent = new Intent(Intent.ACTION_DELETE);
    Uri packageURI = Uri.parse("package:" + packageName);
    intent.setData(packageURI);
    context.startActivity(intent);
}
 
Example 10
Source File: apitils.java    From stynico with MIT License 5 votes vote down vote up
/**
 * 卸载应用
 *
 * @param context     上下文
 * @param packageName 包名
 * @param requestCode 请求码
 */
public static void uninstallApk(Activity context,
                                String packageName, int requestCode) {
    Uri packageURI = Uri.parse("package:" + packageName);
    Intent intent = new Intent(
            Intent.ACTION_DELETE,// 动作:删除
            packageURI // 所要删除程序的地址
    );
    context.startActivityForResult(intent, requestCode);
    //ForResult 等待返回值的发送(扔飞镖)
}
 
Example 11
Source File: AppUtils.java    From Common with Apache License 2.0 5 votes vote down vote up
/**
 * Uninstall the app.
 *
 * @param activity    The activity.
 * @param packageName The name of the package.
 * @param requestCode If >= 0, this code will be returned in
 *                    onActivityResult() when the activity exits.
 */
public static void uninstallApp(final Activity activity,
                                final String packageName,
                                final int requestCode) {
    Intent intent = new Intent(Intent.ACTION_DELETE);
    intent.setData(Uri.parse("package:" + packageName));
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    activity.startActivityForResult(intent, requestCode);
}
 
Example 12
Source File: AppUtils.java    From Common with Apache License 2.0 5 votes vote down vote up
/**
 * Uninstall the app.
 *
 * @param packageName The name of the package.
 */
public static void uninstallApp(final Context context, final String packageName) {
    Intent intent = new Intent(Intent.ACTION_DELETE);
    intent.setData(Uri.parse("package:" + packageName));
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(intent);
}
 
Example 13
Source File: PackageUtils.java    From mobile-manager-tool with MIT License 5 votes vote down vote up
/**
 * uninstall package normal by system intent
 * 
 * @param context
 * @param packageName package name of app
 * @return whether package name is empty
 */
public static boolean uninstallNormal(Context context, String packageName) {
    if (packageName == null || packageName.length() == 0) {
        return false;
    }

    Intent i = new Intent(Intent.ACTION_DELETE, Uri.parse(new StringBuilder(32).append("package:")
            .append(packageName).toString()));
    i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    context.startActivity(i);
    return true;
}
 
Example 14
Source File: AppUtil.java    From AndroidStudyDemo with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 卸载apk
 * @param context     上下文
 * @param packageName 包名
 */
public static void uninstallApk(Context context, String packageName) {
    if (context == null) return;
    if (TextUtils.isEmpty(packageName)) return;
    Intent intent = new Intent(Intent.ACTION_DELETE);
    Uri packageURI = Uri.parse("package:" + packageName);
    intent.setData(packageURI);
    context.startActivity(intent);
}
 
Example 15
Source File: FileListAdapter.java    From FileTransfer with GNU General Public License v3.0 4 votes vote down vote up
private void delete(Context context, String packageName) {
    Uri uri = Uri.fromParts("package", packageName, null);
    Intent intent = new Intent(Intent.ACTION_DELETE, uri);
    context.startActivity(intent);
}
 
Example 16
Source File: APPUtil.java    From DownloadManager with Apache License 2.0 4 votes vote down vote up
/**
 * 卸载APP
 * @param context
 * @param packageName 包名
 */
public static void uninstallAPK(Context context, String packageName) {
    Uri packageURI = Uri.parse("package:" + packageName);
    Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
    context.startActivity(uninstallIntent);
}
 
Example 17
Source File: ManageAddonsActivity.java    From MCPELauncher with Apache License 2.0 4 votes vote down vote up
public void deleteAddon(AddonListItem addon) throws Exception {
	Uri packageURI = Uri.parse("package:" + addon.appInfo.packageName);
	Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageURI);
	startActivityForResult(uninstallIntent, 123);
	setAddonListModified();
}
 
Example 18
Source File: SystemUtils.java    From pandroid with Apache License 2.0 4 votes vote down vote up
public static void uninstallApplication(String packageName, Activity activity) {
    Uri uri = Uri.fromParts("package", packageName, null);
    Intent deleteIntent = new Intent(Intent.ACTION_DELETE, uri);
    activity.startActivity(deleteIntent);
}
 
Example 19
Source File: IntentUtils.java    From Android-UtilCode with Apache License 2.0 2 votes vote down vote up
/**
 * 获取卸载App的意图
 *
 * @param packageName 包名
 * @return intent
 */
public static Intent getUninstallAppIntent(String packageName) {
    Intent intent = new Intent(Intent.ACTION_DELETE);
    intent.setData(Uri.parse("package:" + packageName));
    return intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}
 
Example 20
Source File: IntentUtils.java    From AndroidUtilCode with Apache License 2.0 2 votes vote down vote up
/**
 * Return the intent of uninstall app.
 * <p>Target APIs greater than 25 must hold
 * Must hold {@code <uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />}</p>
 *
 * @param pkgName The name of the package.
 * @return the intent of uninstall app
 */
public static Intent getUninstallAppIntent(final String pkgName) {
    Intent intent = new Intent(Intent.ACTION_DELETE);
    intent.setData(Uri.parse("package:" + pkgName));
    return intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
}