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:com.android.soma.Launcher.java
boolean startApplicationUninstallActivity(ComponentName componentName, int flags) { 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 {/*from www. j ava2 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); startActivity(intent); return true; } }
From source file:com.cognizant.trumobi.PersonaLauncher.java
public void showActions(final PersonaItemInfo info, final View view) { int[] xy = new int[2]; // fills the array with the computed coordinates view.getLocationInWindow(xy);// w w w. j a v a 2 s . co m // rectangle holding the clicked view area Rect rect = new Rect(xy[0], xy[1], xy[0] + view.getWidth(), xy[1] + view.getHeight()); // a new PersonaQuickActionWindow object final PersonaQuickActionWindow qa = new PersonaQuickActionWindow(this, view, rect); view.setTag(R.id.TAG_PREVIEW, qa); // adds an item to the badge and defines the quick action to be // triggered // when the item is clicked on qa.addItem(getResources().getDrawable(android.R.drawable.ic_menu_delete), R.string.menu_delete, new OnClickListener() { public void onClick(View v) { final PersonaLauncherModel model = PersonaLauncher.getModel(); if (info.container == PersonaLauncherSettings.Favorites.CONTAINER_DESKTOP) { if (info instanceof PersonaLauncherAppWidgetInfo) { model.removeDesktopAppWidget((PersonaLauncherAppWidgetInfo) info); } else { model.removeDesktopItem(info); } } else { // in a folder? PersonaFolderInfo source = sModel.getFolderById(PersonaLauncher.this, info.container); if (source instanceof PersonaUserFolderInfo) { final PersonaUserFolderInfo personaUserFolderInfo = (PersonaUserFolderInfo) source; model.removeUserFolderItem(personaUserFolderInfo, info); } } if (info instanceof PersonaUserFolderInfo) { final PersonaUserFolderInfo personaUserFolderInfo = (PersonaUserFolderInfo) info; PersonaLauncherModel.deleteUserFolderContentsFromDatabase(PersonaLauncher.this, personaUserFolderInfo); model.removeUserFolder(personaUserFolderInfo); } else if (info instanceof PersonaLauncherAppWidgetInfo) { final PersonaLauncherAppWidgetInfo personaLauncherAppWidgetInfo = (PersonaLauncherAppWidgetInfo) info; final PersonaLauncherAppWidgetHost appWidgetHost = PersonaLauncher.this .getAppWidgetHost(); PersonaLauncher.this.getWorkspace() .unbindWidgetScrollableId(personaLauncherAppWidgetInfo.appWidgetId); if (appWidgetHost != null) { appWidgetHost.deleteAppWidgetId(personaLauncherAppWidgetInfo.appWidgetId); } } PersonaLauncherModel.deleteItemFromDatabase(PersonaLauncher.this, info); if (view instanceof PersonaActionButton) ((PersonaActionButton) view).UpdateLaunchInfo(null); else ((ViewGroup) view.getParent()).removeView(view); qa.dismiss(); } }); if (info instanceof PersonaApplicationInfo) { qa.addItem(getResources().getDrawable(android.R.drawable.ic_menu_edit), R.string.menu_edit, new OnClickListener() { public void onClick(View v) { editShirtcut((PersonaApplicationInfo) info); qa.dismiss(); } }); } else if (info instanceof PersonaLauncherAppWidgetInfo) { qa.addItem(getResources().getDrawable(android.R.drawable.ic_menu_edit), R.string.menu_edit, new OnClickListener() { public void onClick(View v) { editWidget(view); qa.dismiss(); } }); } if (info instanceof PersonaApplicationInfo || info instanceof PersonaLauncherAppWidgetInfo) { qa.addItem(getResources().getDrawable(android.R.drawable.ic_menu_manage), R.string.menu_uninstall, new OnClickListener() { public void onClick(View v) { String UninstallPkg = null; if (info instanceof PersonaApplicationInfo) { try { final PersonaApplicationInfo appInfo = (PersonaApplicationInfo) info; if (appInfo.iconResource != null) UninstallPkg = appInfo.iconResource.packageName; else { PackageManager mgr = PersonaLauncher.this.getPackageManager(); ResolveInfo res = mgr.resolveActivity(appInfo.intent, 0); UninstallPkg = res.activityInfo.packageName; } // Dont uninstall ADW ;-) if (this.getClass().getPackage().getName().equals(UninstallPkg)) UninstallPkg = null; } catch (Exception e) { PersonaLog.w(LOG_TAG, "Could not load shortcut icon: " + info); UninstallPkg = null; } } else if (info instanceof PersonaLauncherAppWidgetInfo) { PersonaLauncherAppWidgetInfo appwidget = (PersonaLauncherAppWidgetInfo) info; final AppWidgetProviderInfo aw = AppWidgetManager.getInstance(PersonaLauncher.this) .getAppWidgetInfo(appwidget.appWidgetId); if (aw != null) UninstallPkg = aw.provider.getPackageName(); } if (UninstallPkg != null) { Intent uninstallIntent = new Intent(Intent.ACTION_DELETE, Uri.parse("package:" + UninstallPkg)); PersonaLauncher.this.startActivity(uninstallIntent); } qa.dismiss(); } }); } // shows the quick action window on the screen qa.show(); }