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:com.danielhalupka.imageviewer.ImageViewer.java
@Override public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { try {/* w w w.j a va 2s. c o m*/ if (ACTION_VIEW_IMAGE.equals(action)) { JSONObject arg_object = args.getJSONObject(0); Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); String filePath = arg_object.getString("filepath"); intent.setDataAndType(Uri.parse(filePath), "image/*"); this.cordova.getActivity().startActivity(intent); callbackContext.success(); return true; } callbackContext.error("Invalid action"); return false; } catch (JSONException e) { System.err.println("Exception: " + e.getMessage()); callbackContext.error(e.getMessage()); return false; } }
From source file:com.apptentive.android.sdk.module.engagement.interaction.view.NavigateToLinkInteractionView.java
@Override public void doOnCreate(Activity activity, Bundle savedInteraction) { boolean success = false; try {// w w w .j a v a 2s .c o m String url = interaction.getUrl(); Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); switch (interaction.getTarget()) { case New: intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); break; case Self: // Nothing break; default: break; } activity.startActivity(intent); success = true; } catch (ActivityNotFoundException e) { Log.w("NavigateToLink Error: ", e); } finally { JSONObject data = new JSONObject(); try { data.put(NavigateToLinkInteraction.KEY_URL, interaction.getUrl()); data.put(NavigateToLinkInteraction.KEY_TARGET, interaction.getTarget().lowercaseName()); data.put(NavigateToLinkInteraction.EVENT_KEY_SUCCESS, success); } catch (JSONException e) { Log.e("Error creating Event data object.", e); } EngagementModule.engageInternal(activity, interaction, NavigateToLinkInteraction.EVENT_NAME_NAVIGATE, data.toString()); // Always finish this Activity. activity.finish(); } }
From source file:Main.java
/** * Open banking App for given context and secure token. Use this method if you do not use the Pay by Bank app Popup API (which takes care of the banking app * opening).//from ww w . j a va2s . c o m * * @param context The (activity or application) context to start the banking App. * @param secureToken The secure token of the payment for which the banking App is to be started. * @see #isCFIAppAvailable(Context) * @see #showPBBAPopup(FragmentActivity, String, String, PBBAPopupCallback) * @see #showPBBAErrorPopup(FragmentActivity, String, String, String, PBBAPopupCallback) */ public static void openBankingApp(@NonNull Context context, @NonNull final String secureToken) { //noinspection ConstantConditions if (context == null) { throw new IllegalArgumentException("context == null"); } if (TextUtils.isEmpty(secureToken)) { throw new IllegalArgumentException("secureToken is required"); } final Uri zappUri = Uri.parse(String.format(ZAPP_URI_FORMAT_STRING, ZAPP_SCHEME, secureToken)); final Intent bankingAppStartIntent = new Intent(Intent.ACTION_VIEW, zappUri); @SuppressWarnings("BooleanVariableAlwaysNegated") final boolean isActivityContext = context instanceof Activity; if (!isActivityContext) { bankingAppStartIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); } context.startActivity(bankingAppStartIntent); }
From source file:love.juhe.androidmonkey.MonkeyActivityEvent.java
/** * @return Intent for the new activity//www . ja v a 2 s . co m */ private Intent getEvent() { Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setComponent(mApp); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); return intent; }
From source file:com.prey.json.actions.Geofencing.java
public void start(Context ctx, List<ActionResult> lista, JSONObject parameters) { try {//from w ww . j av a 2 s.co m String origin = parameters.getString("origin"); String[] centralPoints = origin.split(","); String longitude = centralPoints[0]; String latitude = centralPoints[1]; String radius = parameters.getString("radius"); Bundle bundle = new Bundle(); bundle.putDouble("longitude", Double.parseDouble(longitude)); bundle.putDouble("latitude", Double.parseDouble(latitude)); bundle.putFloat("radius", Float.parseFloat(radius)); bundle.putInt("type", ProxAlertActivity.START); Intent popup = new Intent(ctx, ProxAlertActivity.class); popup.putExtras(bundle); popup.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); ctx.startActivity(popup); PreyLogger.i("Finish Geofencing start"); } catch (JSONException e) { PreyLogger.e("Error en json:" + e.getMessage(), e); PreyWebServices.getInstance().sendNotifyActionResultPreyHttp(ctx, UtilJson.makeMapParam("start", "geofence", "failed", e.getMessage())); } }
From source file:com.diusrex.toforeground.ToForeground.java
public boolean execute(String className, JSONArray args, CallbackContext callbackContext) throws JSONException { try {//ww w . j av a 2 s. c o m Intent it = new Intent("android.intent.action.MAIN"); String packageName = args.getString(0); Activity activity = this.cordova.getActivity(); it.setComponent(new ComponentName(packageName, packageName + "." + className)); it.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); Context context = activity.getApplicationContext(); context.startActivity(it); } catch (Exception e) { return false; } return true; }
From source file:id.zelory.tanipedia.activity.LoginActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { if (PrefUtils.ambilString(this, "nama") != null) { Intent intent = new Intent(LoginActivity.this, CuacaActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); startActivity(intent);//from w ww.j a v a 2 s . c o m } super.onCreate(savedInstanceState); setContentView(R.layout.activity_login); Animation animation = AnimationUtils.loadAnimation(this, R.anim.simple_grow); findViewById(R.id.tanipedia).startAnimation(animation); findViewById(R.id.card).startAnimation(animation); Button login = (Button) findViewById(R.id.login); login.startAnimation(animation); login.setOnClickListener(this); TextView daftar = (TextView) findViewById(R.id.register); daftar.startAnimation(animation); daftar.setOnClickListener(this); editEmail = (EditText) findViewById(R.id.email); editPass = (EditText) findViewById(R.id.password); }
From source file:edu.stanford.mobisocial.dungbeetle.feed.objects.InviteToWebSessionObj.java
public void handleDirectMessage(Context context, Contact from, JSONObject obj) { String arg = obj.optString(ARG); Intent launch = new Intent(); launch.setAction(Intent.ACTION_MAIN); launch.addCategory(Intent.CATEGORY_LAUNCHER); launch.putExtra("android.intent.extra.APPLICATION_ARGUMENT", arg); launch.putExtra("creator", false); launch.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); String webUrl = obj.optString(WEB_URL); launch.setData(Uri.parse(webUrl));/*from w ww .ja va 2s . c o m*/ PendingIntent contentIntent = PendingIntent.getActivity(context, 0, launch, PendingIntent.FLAG_CANCEL_CURRENT); (new PresenceAwareNotify(context)).notify("New Invitation", "Invitation received", "Click to launch application.", contentIntent); }
From source file:fr.cph.stock.android.StockTrackerApp.java
/** * This function logout the user and removes its login/password from the preferences. It also loads the login activity * //from w ww. ja va 2s. c om * @param activity * the activity to finish */ public void logOut(Activity activity) { SharedPreferences settings = getSharedPreferences(BaseActivity.PREFS_NAME, 0); String login = settings.getString("login", null); String password = settings.getString("password", null); if (login != null) { settings.edit().remove("login").commit(); } if (password != null) { settings.edit().remove("password").commit(); } activity.setResult(100); activity.finish(); Intent intent = new Intent(this, LoginActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); }
From source file:Main.java
public static void openFile(Context context, File url) throws IOException { // Create URI File file = url;/* www . jav a 2 s . c om*/ Uri uri = Uri.fromFile(file); Intent intent = new Intent(Intent.ACTION_VIEW); // Check what kind of file you are trying to open, by comparing the url with extensions. // When the if condition is matched, plugin sets the correct intent (mime) type, // so Android knew what application to use to open the file if (url.toString().contains(".doc") || url.toString().contains(".docx")) { // Word document intent.setDataAndType(uri, "application/msword"); } else if (url.toString().contains(".pdf")) { // PDF file intent.setDataAndType(uri, "application/pdf"); } else if (url.toString().contains(".ppt") || url.toString().contains(".pptx")) { // Powerpoint file intent.setDataAndType(uri, "application/vnd.ms-powerpoint"); } else if (url.toString().contains(".xls") || url.toString().contains(".xlsx")) { // Excel file intent.setDataAndType(uri, "application/vnd.ms-excel"); } else if (url.toString().contains(".zip") || url.toString().contains(".rar")) { // WAV audio file intent.setDataAndType(uri, "application/zip"); } else if (url.toString().contains(".rtf")) { // RTF file intent.setDataAndType(uri, "application/rtf"); } else if (url.toString().contains(".wav") || url.toString().contains(".mp3")) { // WAV audio file intent.setDataAndType(uri, "audio/x-wav"); } else if (url.toString().contains(".gif")) { // GIF file intent.setDataAndType(uri, "image/gif"); } else if (url.toString().contains(".jpg") || url.toString().contains(".jpeg") || url.toString().contains(".png")) { // JPG file intent.setDataAndType(uri, "image/jpeg"); } else if (url.toString().contains(".txt")) { // Text file intent.setDataAndType(uri, "text/plain"); } else if (url.toString().contains(".3gp") || url.toString().contains(".mpg") || url.toString().contains(".mpeg") || url.toString().contains(".mpe") || url.toString().contains(".mp4") || url.toString().contains(".avi")) { // Video files intent.setDataAndType(uri, "video/*"); } else { //if you want you can also define the intent type for any other file //additionally use else clause below, to manage other unknown extensions //in this case, Android will show all applications installed on the device //so you can choose which application to use intent.setDataAndType(uri, "*/*"); } intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(intent); }