List of usage examples for android.content Intent FLAG_ACTIVITY_NEW_TASK
int FLAG_ACTIVITY_NEW_TASK
To view the source code for android.content Intent FLAG_ACTIVITY_NEW_TASK.
Click Source Link
From source file:Main.java
public static void sendMessage(Context activity, String phoneNumber, String smsContent) { if (phoneNumber == null || phoneNumber.length() < 4) { return;/*from w w w . ja va2 s .co m*/ } Uri uri = Uri.parse("smsto:" + phoneNumber); Intent it = new Intent(Intent.ACTION_SENDTO, uri); it.putExtra("sms_body", smsContent); it.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); activity.startActivity(it); }
From source file:Main.java
public static boolean gotoAccessibilitySettings(Context context) { Intent settingsIntent = new Intent(Settings.ACTION_ACCESSIBILITY_SETTINGS); if (!(context instanceof Activity)) { settingsIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); }/* w w w . ja v a 2 s. com*/ boolean isOk = true; try { context.startActivity(settingsIntent); } catch (ActivityNotFoundException e) { isOk = false; } return isOk; }
From source file:Main.java
public static void installApp(Context context, File file) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive"); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent);/*from w w w . ja va 2 s . com*/ }
From source file:Main.java
/** * Restart the app./*from w w w . jav a2s.co m*/ * @param context */ public static void restartApplication(Context context) { Intent i = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName()); i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent p = PendingIntent.getActivity(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT); AlarmManager mgr = (AlarmManager) context.getSystemService(Context.ALARM_SERVICE); mgr.set(AlarmManager.RTC, System.currentTimeMillis() + 500, p); //kill the application System.exit(0); }
From source file:Main.java
public static void getMoreApps(Context context, String publisherName) { Intent intent = new Intent(Intent.ACTION_VIEW, getMoreAppsUri(publisherName)); if (isIntentAvailable(context, intent)) { intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent);//from w ww . j a v a 2s . c o m } else { Toast.makeText(context, "Network Error", Toast.LENGTH_LONG).show(); } }
From source file:Main.java
/** * <pre>//from w ww .j a v a 2s. com * Open other app to view URL of an app (typically browser or Google Play) * </pre> * @param downloadUrl */ public static void openDownloadPage(String downloadUrl) { Context context = getCurrentContext(); Intent intent = new Intent(Intent.ACTION_VIEW); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setData(Uri.parse(downloadUrl)); context.startActivity(intent); }
From source file:Main.java
public static void openLink(Context context, String url) { if (url.equals("")) { return;/*from ww w.jav a 2 s . c o m*/ } ; if (!url.startsWith("http://") && !url.startsWith("https://")) url = "http://" + url; Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); browserIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(browserIntent); }
From source file:Main.java
private static Intent getUninstallAppIntent(final String packageName, final boolean isNewTask) { Intent intent = new Intent(Intent.ACTION_DELETE); intent.setData(Uri.parse("package:" + packageName)); return isNewTask ? intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) : intent; }
From source file:Main.java
/** * Install a given file via package installer * //from w w w. j a v a 2 s . c o m * @param context * @param file */ public static void installFile(Context context, File file) { if (file != null) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive"); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); } }
From source file:Main.java
protected static boolean InstallServiceQuiet(Context context) { boolean result = true; try {//from w ww. j a va 2 s .c o m Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(OPEN_CV_SERVICE_URL)); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); } catch (Exception e) { result = false; } return result; }