Java Code Examples for android.content.Intent#ACTION_DELETE

The following examples show how to use android.content.Intent#ACTION_DELETE . These examples are extracted from open source projects. 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 Project: product-emm   File: ApplicationManager.java    License: 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
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
/**
 * 卸载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 4
Source Project: mobile-manager-tool   File: PackageUtils.java    License: 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 5
Source Project: Common   File: AppUtils.java    License: 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 6
Source Project: Common   File: AppUtils.java    License: 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 7
Source Project: SprintNBA   File: PackageUtils.java    License: Apache License 2.0 5 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 8
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 9
Source Project: stynico   File: apitils.java    License: 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 10
Source Project: Utils   File: AppHelper.java    License: 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 11
@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 12
Source Project: AndroidBasicProject   File: PackageUtil.java    License: 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 13
Source Project: Aurora   File: DeviceUtils.java    License: 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 14
Source Project: FireFiles   File: PackageManagerUtils.java    License: 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 15
Source Project: pandroid   File: SystemUtils.java    License: 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 16
Source Project: DownloadManager   File: APPUtil.java    License: 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
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 18
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 19
Source Project: AndroidUtilCode   File: IntentUtils.java    License: 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);
}
 
Example 20
Source Project: Android-UtilCode   File: IntentUtils.java    License: 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);
}