List of usage examples for android.content Intent FLAG_ACTIVITY_REORDER_TO_FRONT
int FLAG_ACTIVITY_REORDER_TO_FRONT
To view the source code for android.content Intent FLAG_ACTIVITY_REORDER_TO_FRONT.
Click Source Link
From source file:Main.java
public static void front(Context packageContext, Class<?> cls) { Intent intent = new Intent(packageContext, cls); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); packageContext.startActivity(intent); intent = null;/* w ww . ja v a2s.co m*/ }
From source file:Main.java
public static void openActivity(Context context, Class<Activity> cls) { if (null == context || null == cls) return;/*from w w w . j a v a 2 s . com*/ Intent i = new Intent(context, cls); i.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); context.startActivity(i); }
From source file:de.Maxr1998.xposed.maxlock.ui.LockActivity.java
@SuppressLint("WorldReadableFiles") public static void directUnlock(Activity caller, Intent orig, String pkgName) { try {/*from w w w .ja v a2 s. c om*/ //noinspection deprecation caller.getSharedPreferences(Common.PREFS_PACKAGES, MODE_WORLD_READABLE).edit() .putLong(pkgName + "_tmp", System.currentTimeMillis()).commit(); orig.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); caller.startActivity(orig); } catch (Exception e) { Intent intent_option = caller.getPackageManager().getLaunchIntentForPackage(pkgName); intent_option.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); caller.startActivity(intent_option); } finally { caller.finish(); } }
From source file:org.cnx.openstaxcnxmusic.activity.AboutActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { Intent mainIntent = new Intent(getApplicationContext(), LandingActivity.class); mainIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); startActivity(mainIntent);/*from w w w . j ava2 s . c o m*/ } return true; }
From source file:org.cnx.openstaxcnxmusic.activity.BookmarkActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == android.R.id.home) { Intent mainIntent = new Intent(getApplicationContext(), LandingActivity.class); mainIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); startActivity(mainIntent);/*from ww w . j av a2 s . c o m*/ return true; } else { MenuHelper mh = new MenuHelper(); return mh.handleContextMenu(item.getItemId(), this, null); } }
From source file:net.zionsoft.obadiah.ui.activities.SearchActivity.java
public static Intent newStartReorderToTopIntent(Context context) { final Intent startIntent = new Intent(context, SearchActivity.class); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { // there's some horrible issue with FLAG_ACTIVITY_REORDER_TO_FRONT for KitKat and above // ref. https://code.google.com/p/android/issues/detail?id=63570 startIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); }// www . ja v a 2 s . c o m return startIntent; }
From source file:com.commonsware.android.sawmonitor.SAWDetector.java
static void seeSAW(Context ctxt, String pkg, String operation) { if (hasSAW(ctxt, pkg)) { Uri pkgUri = Uri.parse("package:" + pkg); Intent manage = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION); manage.setData(pkgUri);/* w w w .j a v a 2 s. co m*/ Intent whitelist = new Intent(ctxt, WhitelistReceiver.class); whitelist.setData(pkgUri); Intent main = new Intent(ctxt, MainActivity.class); main.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); NotificationManager mgr = (NotificationManager) ctxt.getSystemService(Context.NOTIFICATION_SERVICE); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && mgr.getNotificationChannel(CHANNEL_WHATEVER) == null) { mgr.createNotificationChannel(new NotificationChannel(CHANNEL_WHATEVER, "Whatever", NotificationManager.IMPORTANCE_DEFAULT)); } NotificationCompat.Builder b = new NotificationCompat.Builder(ctxt, CHANNEL_WHATEVER); String text = String.format(ctxt.getString(R.string.msg_requested), operation, pkg); b.setAutoCancel(true).setDefaults(Notification.DEFAULT_ALL).setWhen(System.currentTimeMillis()) .setContentTitle(ctxt.getString(R.string.msg_detected)).setContentText(text) .setSmallIcon(android.R.drawable.stat_notify_error) .setTicker(ctxt.getString(R.string.msg_detected)) .setContentIntent(PendingIntent.getActivity(ctxt, 0, manage, PendingIntent.FLAG_UPDATE_CURRENT)) .addAction(R.drawable.ic_verified_user_24dp, ctxt.getString(R.string.msg_whitelist), PendingIntent.getBroadcast(ctxt, 0, whitelist, 0)) .addAction(R.drawable.ic_settings_24dp, ctxt.getString(R.string.msg_settings), PendingIntent.getActivity(ctxt, 0, main, 0)); mgr.notify(NOTIFY_ID, b.build()); } }
From source file:com.marakana.android.yamba.BaseActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { int id = item.getItemId(); if ((android.R.id.home == id) || (R.id.menu_timeline == id)) { startActivity(new Intent(this, TimelineActivity.class).addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)); return true; }/*from w ww . j a v a 2 s. com*/ if (R.id.menu_status == id) { startActivity(new Intent(this, StatusActivity.class).addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT)); return true; } if (R.id.menu_about == id) { Toast.makeText(this, R.string.about, Toast.LENGTH_LONG).show(); return true; } return super.onOptionsItemSelected(item); }
From source file:com.example.android.repeatingalarm.RepeatingAlarmFragment.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.sample_action) { // BEGIN_INCLUDE (intent_fired_by_alarm) // First create an intent for the alarm to activate. // This code simply starts an Activity, or brings it to the front if it has already // been created. Intent intent = new Intent(getActivity(), MainActivity.class); intent.setAction(Intent.ACTION_MAIN); intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); // END_INCLUDE (intent_fired_by_alarm) // BEGIN_INCLUDE (pending_intent_for_alarm) // Because the intent must be fired by a system service from outside the application, // it's necessary to wrap it in a PendingIntent. Providing a different process with // a PendingIntent gives that other process permission to fire the intent that this // application has created. // Also, this code creates a PendingIntent to start an Activity. To create a // BroadcastIntent instead, simply call getBroadcast instead of getIntent. PendingIntent pendingIntent = PendingIntent.getActivity(getActivity(), REQUEST_CODE, intent, 0); // END_INCLUDE (pending_intent_for_alarm) // BEGIN_INCLUDE (configure_alarm_manager) // There are two clock types for alarms, ELAPSED_REALTIME and RTC. // ELAPSED_REALTIME uses time since system boot as a reference, and RTC uses UTC (wall // clock) time. This means ELAPSED_REALTIME is suited to setting an alarm according to // passage of time (every 15 seconds, 15 minutes, etc), since it isn't affected by // timezone/locale. RTC is better suited for alarms that should be dependant on current // locale. // Both types have a WAKEUP version, which says to wake up the device if the screen is // off. This is useful for situations such as alarm clocks. Abuse of this flag is an // efficient way to skyrocket the uninstall rate of an application, so use with care. // For most situations, ELAPSED_REALTIME will suffice. int alarmType = AlarmManager.ELAPSED_REALTIME; final int FIFTEEN_SEC_MILLIS = 15000; // The AlarmManager, like most system services, isn't created by application code, but // requested from the system. AlarmManager alarmManager = (AlarmManager) getActivity().getSystemService(getActivity().ALARM_SERVICE); // setRepeating takes a start delay and period between alarms as arguments. // The below code fires after 15 seconds, and repeats every 15 seconds. This is very // useful for demonstration purposes, but horrendous for production. Don't be that dev. alarmManager.setRepeating(alarmType, SystemClock.elapsedRealtime() + FIFTEEN_SEC_MILLIS, FIFTEEN_SEC_MILLIS, pendingIntent); // END_INCLUDE (configure_alarm_manager); Log.i("RepeatingAlarmFragment", "Alarm set."); }//from w w w. ja v a 2 s.com return true; }
From source file:br.ajmarques.cordova.plugin.localnotification.ReceiverActivity.java
/** * Launch main intent for package.// w w w .j ava2 s . c o m */ private void launchMainIntent() { Context context = getApplicationContext(); String packageName = context.getPackageName(); Intent launchIntent = context.getPackageManager().getLaunchIntentForPackage(packageName); launchIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP); context.startActivity(launchIntent); }