List of usage examples for android.os StrictMode setVmPolicy
public static void setVmPolicy(final VmPolicy policy)
From source file:com.android.launcher3.Launcher.java
private void startShortcutIntentSafely(Intent intent, Bundle optsBundle, ItemInfo info) { try {//w w w .j a va 2 s. co m StrictMode.VmPolicy oldPolicy = StrictMode.getVmPolicy(); try { // Temporarily disable deathPenalty on all default checks. For eg, shortcuts // containing file Uri's would cause a crash as penaltyDeathOnFileUriExposure // is enabled by default on NYC. StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build()); if (info.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) { String id = ((ShortcutInfo) info).getDeepShortcutId(); String packageName = intent.getPackage(); LauncherAppState.getInstance().getShortcutManager().startShortcut(packageName, id, intent.getSourceBounds(), optsBundle, info.user); } else { // Could be launching some bookkeeping activity startActivity(intent, optsBundle); } } finally { StrictMode.setVmPolicy(oldPolicy); } } catch (SecurityException e) { // Due to legacy reasons, direct call shortcuts require Launchers to have the // corresponding permission. Show the appropriate permission prompt if that // is the case. if (intent.getComponent() == null && Intent.ACTION_CALL.equals(intent.getAction()) && checkSelfPermission(Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) { setWaitingForResult(PendingRequestArgs.forIntent(REQUEST_PERMISSION_CALL_PHONE, intent, info)); requestPermissions(new String[] { Manifest.permission.CALL_PHONE }, REQUEST_PERMISSION_CALL_PHONE); } else { // No idea why this was thrown. throw e; } } }