List of usage examples for android.content Intent ACTION_DELETE
String ACTION_DELETE
To view the source code for android.content Intent ACTION_DELETE.
Click Source Link
From source file:cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.data.receiver.NotificationHelper.java
/** * Fires notifications that have elapsed and sets an alarm to be woken at * the next notification.//from w w w.j av a2s. c o m * <p/> * If the intent action is ACTION_DELETE, will delete the notification with * the indicated ID, and cancel it from any active notifications. */ @Override public void onReceive(Context context, Intent intent) { if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction()) || Intent.ACTION_RUN.equals(intent.getAction())) { // Can't cancel anything. Just schedule and notify at end } else { // Always cancel cancelNotification(context, intent.getData()); if (Intent.ACTION_DELETE.equals(intent.getAction()) || ACTION_RESCHEDULE.equals(intent.getAction())) { // Just a notification cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.data.model.sql.Notification .deleteOrReschedule(context, intent.getData()); } else if (ACTION_SNOOZE.equals(intent.getAction())) { // msec/sec * sec/min * 30 long delay30min = 1000 * 60 * 30; final Calendar now = Calendar.getInstance(); cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.data.model.sql.Notification .setTime(context, intent.getData(), delay30min + now.getTimeInMillis()); } else if (ACTION_COMPLETE.equals(intent.getAction())) { // Complete note Task.setCompletedSynced(context, true, intent.getLongExtra(ARG_TASKID, -1)); // Delete notifications with the same task id cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.data.model.sql.Notification .removeWithTaskIdsSynced(context, intent.getLongExtra(ARG_TASKID, -1)); } } notifyPast(context, true); scheduleNext(context); }
From source file:cm.aptoide.pt.ApkInfo.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case 0://from ww w .jav a 2 s.c o m Uri uri = Uri.fromParts("package", viewApk.getApkid(), null); Intent intent = new Intent(Intent.ACTION_DELETE, uri); startActivity(intent); finish(); break; case 1: Intent i = new Intent(); i.setAction(android.content.Intent.ACTION_VIEW); i.setData(Uri.parse("market://details?id=" + viewApk.getApkid())); try { startActivity(i); } catch (ActivityNotFoundException e) { Toast toast = Toast.makeText(context, context.getString(R.string.error_no_market), Toast.LENGTH_SHORT); toast.show(); } break; default: break; } return true; }
From source file:com.yeldi.yeldibazaar.AppDetails.java
private void removeApk(String id) { PackageInfo pkginfo;/*from w ww . java 2 s . com*/ try { pkginfo = mPm.getPackageInfo(id, 0); } catch (NameNotFoundException e) { Log.d("FDroid", "Couldn't find package " + id + " to uninstall."); return; } Uri uri = Uri.fromParts("package", pkginfo.packageName, null); Intent intent = new Intent(Intent.ACTION_DELETE, uri); startActivityForResult(intent, REQUEST_UNINSTALL); ((FDroidApp) getApplication()).invalidateApp(id); }
From source file:org.wso2.iot.agent.api.ApplicationManager.java
/** * Removes an application from the device. * * @param packageName - Application package name should be passed in as a String. */// www . j a v a2 s.co m public void uninstallApplication(String packageName, String schedule) throws AndroidAgentException { String packageUriString = packageName; if (packageName != null) { if (!packageName.contains(resources.getString(R.string.application_package_prefix))) { packageUriString = resources.getString(R.string.application_package_prefix) + packageName; } else { packageName = packageName.replace(resources.getString(R.string.application_package_prefix), ""); } } if (!this.isPackageInstalled(packageName)) { String message = "Package is not installed in the device or invalid package name"; Preference.putString(context, context.getResources().getString(R.string.app_uninstall_status), APP_STATE_UNINSTALLED_FAILED); Preference.putString(context, context.getResources().getString(R.string.app_uninstall_failed_message), message); throw new AndroidAgentException("Package is not installed in the device"); } 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) { Preference.putString(context, context.getResources().getString(R.string.app_uninstall_status), APP_STATE_UNINSTALLED); Preference.putString(context, context.getResources().getString(R.string.app_uninstall_failed_message), null); CommonUtils.callSystemApp(context, Constants.Operation.SILENT_UNINSTALL_APPLICATION, "", packageUriString); } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && policyManager.isDeviceOwnerApp(Constants.AGENT_PACKAGE)) { if (silentlyUninstallApplication(packageName)) { Preference.putString(context, context.getResources().getString(R.string.app_uninstall_status), APP_STATE_UNINSTALLED); } else { Preference.putString(context, context.getResources().getString(R.string.app_uninstall_status), APP_STATE_UNINSTALLED_FAILED); } Preference.putString(context, context.getResources().getString(R.string.app_uninstall_failed_message), null); } else { Preference.putString(context, context.getResources().getString(R.string.app_uninstall_status), APP_STATE_UNINSTALLED); Preference.putString(context, context.getResources().getString(R.string.app_uninstall_failed_message), null); Uri packageUri = Uri.parse(packageUriString); Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, packageUri); uninstallIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(uninstallIntent); } }
From source file:org.jsharkey.grouphome.LauncherActivity.java
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) { if (!(v.getTag() instanceof EntryInfo)) return;/*from w w w. j a va 2 s .co m*/ EntryInfo info = (EntryInfo) v.getTag(); final String packageName = info.resolveInfo.activityInfo.applicationInfo.packageName; menu.setHeaderTitle(info.title); Intent detailsIntent = new Intent(); detailsIntent.setClassName("com.android.settings", "com.android.settings.InstalledAppDetails"); detailsIntent.putExtra("com.android.settings.ApplicationPkgName", packageName); menu.add("App details").setIntent(detailsIntent); Intent deleteIntent = new Intent(Intent.ACTION_DELETE); deleteIntent.setData(Uri.parse("package:" + packageName)); menu.add("Uninstall").setIntent(deleteIntent); }
From source file:com.sentaroh.android.TaskAutomation.Config.ActivityMain.java
final private void uninstallApplication() { NotifyEvent ntfy = new NotifyEvent(mContext); ntfy.setListener(new NotifyEventListener() { @Override/*www. jav a2 s . co m*/ public void positiveResponse(Context c, Object[] o) { switchDeviceAdminStatus(false); getPrefsMgr().edit().putBoolean(getString(R.string.settings_main_device_admin), false).commit(); Uri uri = Uri.fromParts("package", getPackageName(), null); Intent intent = new Intent(Intent.ACTION_DELETE, uri); startActivity(intent); } @Override public void negativeResponse(Context c, Object[] o) { } }); if (mEnvParms.settingDeviceAdmin) { mGlblParms.commonDlg.showCommonDialog(true, "W", getString(R.string.msgs_menu_uninstall_subtitle), getString(R.string.msgs_menu_uninstall_message), ntfy); } else ntfy.notifyToListener(true, null); }
From source file:RhodesService.java
public static void uninstallApplication(String appName) { try {// www . j a va2s .c o m Uri packageUri = Uri.parse("package:" + appName); Intent intent = new Intent(Intent.ACTION_DELETE, packageUri); RhodesService.getContext().startActivity(intent); } catch (Exception e) { Logger.E(TAG, "Can't uninstall application " + appName + ": " + e.getMessage()); } }
From source file:org.uguess.android.sysinfo.ApplicationManager.java
private void doUninstall() { final List<AppInfoHolder> sels = getSelected(getListView()); if (sels == null || sels.size() == 0) { Util.shortToast(getActivity(), R.string.no_app_selected); } else {//from ww w . ja v a2 s . c o m OnClickListener listener = new OnClickListener() { public void onClick(DialogInterface dialog, int which) { boolean canUninstall = false; for (int i = 0, size = sels.size(); i < size; i++) { ApplicationInfo app = sels.get(i).appInfo; Intent it = new Intent(Intent.ACTION_DELETE, Uri.parse("package:" //$NON-NLS-1$ + app.packageName)); if (!canUninstall) { List<ResolveInfo> acts = getActivity().getPackageManager().queryIntentActivities(it, 0); canUninstall = acts.size() > 0; } if (canUninstall) { startActivity(it); } } if (!canUninstall) { Util.shortToast(getActivity(), R.string.uninstall_fail); Log.d(ApplicationManager.class.getName(), "No activity found to handle the uninstall request."); //$NON-NLS-1$ } } }; new AlertDialog.Builder(getActivity()).setTitle(R.string.warning).setMessage(R.string.uninstall_msg) .setPositiveButton(android.R.string.ok, listener) .setNegativeButton(android.R.string.cancel, null).create().show(); } }
From source file:com.android.leanlauncher.LauncherTransitionable.java
boolean startApplicationUninstallActivity(ComponentName componentName, int flags, UserHandleCompat user) { if ((flags & AppInfo.DOWNLOADED_FLAG) == 0) { // System applications cannot be installed. For now, show a toast explaining that. // We may give them the option of disabling apps this way. int messageId = R.string.uninstall_system_app_text; Toast.makeText(this, messageId, Toast.LENGTH_SHORT).show(); return false; } else {/*w ww . jav a2 s .c o m*/ String packageName = componentName.getPackageName(); String className = componentName.getClassName(); Intent intent = new Intent(Intent.ACTION_DELETE, Uri.fromParts("package", packageName, className)); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); if (user != null) { user.addToIntent(intent, Intent.EXTRA_USER); } startActivity(intent); return true; } }
From source file:com.android.launcher2.Launcher.java
void startApplicationUninstallActivity(ApplicationInfo appInfo) { if ((appInfo.flags & ApplicationInfo.DOWNLOADED_FLAG) == 0) { // System applications cannot be installed. For now, show a toast explaining that. // We may give them the option of disabling apps this way. int messageId = R.string.uninstall_system_app_text; Toast.makeText(this, messageId, Toast.LENGTH_SHORT).show(); } else {//from ww w .j ava 2 s . c o m String packageName = appInfo.componentName.getPackageName(); String className = appInfo.componentName.getClassName(); Intent intent = new Intent(Intent.ACTION_DELETE, Uri.fromParts("package", packageName, className)); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); startActivity(intent); } }