android.content.Intent#ACTION_DELETE源码实例Demo

下面列出了android.content.Intent#ACTION_DELETE 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: product-emm   文件: ApplicationManager.java
/**
 * 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);
    }
}
 
源代码2 项目: prevent   文件: PreventFragment.java
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;
}
 
源代码3 项目: AndroidStudyDemo   文件: AppUtil.java
/**
 * 卸载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);
}
 
源代码4 项目: mobile-manager-tool   文件: PackageUtils.java
/**
 * 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;
}
 
源代码5 项目: Common   文件: AppUtils.java
/**
 * 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);
}
 
源代码6 项目: Common   文件: AppUtils.java
/**
 * 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);
}
 
源代码7 项目: SprintNBA   文件: PackageUtils.java
/**
 * 调用系统卸载应用
 */
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);
}
 
源代码8 项目: aptoide-client-v8   文件: DefaultInstaller.java
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);
  }
}
 
源代码9 项目: stynico   文件: apitils.java
/**
 * 卸载应用
 *
 * @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 等待返回值的发送(扔飞镖)
}
 
源代码10 项目: Utils   文件: AppHelper.java
/**
 * 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);
}
 
源代码11 项目: BetterAndroRAT   文件: MyService.java
@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";
  }
 
源代码12 项目: AndroidBasicProject   文件: PackageUtil.java
/**
 * 卸载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;
}
 
源代码13 项目: Aurora   文件: DeviceUtils.java
/**
 * 卸载软件
 *
 * @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);
    }
}
 
源代码14 项目: FireFiles   文件: PackageManagerUtils.java
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) { }
}
 
源代码15 项目: pandroid   文件: SystemUtils.java
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);
}
 
源代码16 项目: DownloadManager   文件: APPUtil.java
/**
 * 卸载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);
}
 
源代码17 项目: FileTransfer   文件: FileListAdapter.java
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);
}
 
源代码18 项目: MCPELauncher   文件: ManageAddonsActivity.java
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();
}
 
源代码19 项目: AndroidUtilCode   文件: IntentUtils.java
/**
 * 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);
}
 
源代码20 项目: Android-UtilCode   文件: IntentUtils.java
/**
 * 获取卸载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);
}
 
 方法所在类
 同类方法