List of usage examples for android.content Intent FLAG_ACTIVITY_SINGLE_TOP
int FLAG_ACTIVITY_SINGLE_TOP
To view the source code for android.content Intent FLAG_ACTIVITY_SINGLE_TOP.
Click Source Link
From source file:de.qspool.clementineremote.ui.ConnectActivity.java
/** * We connected to clementine successfully. Now open other view *//*from w w w .j a v a2 s . co m*/ void showPlayerDialog() { if (mClementineMDns != null) { mClementineMDns.stopServiceDiscovery(); } // Start the player dialog Intent playerDialog = new Intent(this, MainActivity.class); playerDialog.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NO_ANIMATION); startActivityForResult(playerDialog, ID_PLAYER_DIALOG); }
From source file:org.akvo.caddisfly.ui.activity.MainActivity.java
private void playVideo() { File sdDir = getExternalFilesDir(null); final File videoFile = new File(sdDir, "training.mp4"); if (!videoFile.exists()) { if (NetworkUtils.checkInternetConnection(this)) { final Intent intent = new Intent(this, VideoActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); startActivity(intent);//from w w w .j av a 2 s. c o m } } else { final Intent intent = new Intent(this, VideoActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); startActivity(intent); } }
From source file:com.google.appinventor.components.runtime.ProbeBase.java
@SimpleFunction(description = "Create a notication with message to wake up " + "another activity when tap on the notification") public void CreateNotification(String title, String text, boolean enabledSound, boolean enabledVibrate, String packageName, String className, String extraKey, String extraVal) throws ClassNotFoundException { Intent activityToLaunch = new Intent(Intent.ACTION_MAIN); Log.i(TAG, "packageName: " + packageName); Log.i(TAG, "className: " + className); // for local AI instance, all classes are under the package // "appinventor.ai_test" // but for those runs on Google AppSpot(AppEngine), the package name will be // "appinventor.ai_GoogleAccountUserName" // e.g. pakageName = appinventor.ai_HomerSimpson.HelloPurr // && className = appinventor.ai_HomerSimpson.HelloPurr.Screen1 ComponentName component = new ComponentName(packageName, className); activityToLaunch.setComponent(component); activityToLaunch.putExtra(extraKey, extraVal); Log.i(TAG, "we found the class for intent to send into notificaiton"); activityToLaunch.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); mContentIntent = PendingIntent.getActivity(mainUIThreadActivity, 0, activityToLaunch, 0); Long currentTimeMillis = System.currentTimeMillis(); notification = new Notification(R.drawable.stat_notify_chat, "Activate Notification!", currentTimeMillis); Log.i(TAG, "After creating notification"); notification.contentIntent = mContentIntent; notification.flags = Notification.FLAG_AUTO_CANCEL; // reset the notification notification.defaults = 0;/*from w ww. j a v a 2s .c o m*/ if (enabledSound) notification.defaults |= Notification.DEFAULT_SOUND; if (enabledVibrate) notification.defaults |= Notification.DEFAULT_VIBRATE; notification.setLatestEventInfo(mainUIThreadActivity, (CharSequence) title, (CharSequence) text, mContentIntent); Log.i(TAG, "after updated notification contents"); mNM.notify(PROBE_NOTIFICATION_ID, notification); Log.i(TAG, "notified"); }
From source file:org.kaoriha.phonegap.plugins.releasenotification.Notifier.java
private void pollBackground() { if (getToken() == null) { rescheduleAfterFail();//w w w. j a v a 2 s . c om return; } ToNextReleasePolling tp = new ToNextReleasePolling(); tp.poll(); if (tp.isFailed) { Log.d(TAG, "ToNextReleasePolling failed"); rescheduleAfterFail(); return; } CataloguePolling cp = new CataloguePolling(); cp.poll(); if (cp.isFailed) { Log.d(TAG, "CataloguePolling failed"); rescheduleAfterFail(); return; } if (!cp.isNew) { if (tp.toNextRelease == -1) { schedule(RESCHEDULE_NEXT_UNKNOWN_SPAN); } else { schedule(tp.toNextRelease); } Log.d(TAG, "CataloguePolling not new"); return; } String pushMessage; if (cp.catalogue.has(CATALOGUE_PUSH_MESSAGE_KEY)) { try { pushMessage = cp.catalogue.getString(CATALOGUE_PUSH_MESSAGE_KEY); } catch (JSONException e) { Log.i(TAG, "pollBackground()", e); pushMessage = pref.getString(SPKEY_DEFAULT_PUSH_MESSAGE, null); } } else { pushMessage = pref.getString(SPKEY_DEFAULT_PUSH_MESSAGE, null); } String lastSid; try { lastSid = getLastSid(cp.catalogue); if (lastSid.equals(pref.getString(SPKEY_LAST_SID, null))) { schedule(tp.toNextRelease); } } catch (JSONException e) { Log.d(TAG, "bad JSON", e); rescheduleAfterFail(); return; } int icon = R.drawable.notification; Notification n = new Notification(icon, pushMessage, System.currentTimeMillis()); n.flags = Notification.FLAG_AUTO_CANCEL; Intent i = new Intent(ctx, FlowerflowerActivity.class); i.setAction(Intent.ACTION_MAIN); i.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent pi = PendingIntent.getActivity(ctx, 0, i, 0); n.setLatestEventInfo(ctx.getApplicationContext(), pref.getString(SPKEY_TITLE, null), pushMessage, pi); NotificationManager nm = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(NOTIFICATION_ID, n); pref.edit().putString(SPKEY_LAST_SID, lastSid).putString(SPKEY_LAST_CATALOGUE_ETAG, cp.etag).commit(); clearFailRepeat(); schedule(tp.toNextRelease); Log.d(TAG, "pollBackground() success"); }
From source file:im.vector.receiver.VectorUniversalLinkReceiver.java
/** * Open the room activity with the dedicated parameters * * @param context the context.// w ww .ja v a 2 s . c o m */ private void openRoomActivity(Context context) { HashMap<String, Object> params = new HashMap<>(); params.put(VectorRoomActivity.EXTRA_MATRIX_ID, mSession.getMyUserId()); params.put(VectorRoomActivity.EXTRA_ROOM_ID, mParameters.get(ULINK_ROOM_ID_OR_ALIAS_KEY)); if (mParameters.containsKey(ULINK_EVENT_ID_KEY)) { params.put(VectorRoomActivity.EXTRA_EVENT_ID, mParameters.get(ULINK_EVENT_ID_KEY)); } // clear the activity stack to home activity Intent intent = new Intent(context, VectorHomeActivity.class); intent.setFlags( Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra(VectorHomeActivity.EXTRA_JUMP_TO_ROOM_PARAMS, params); context.startActivity(intent); }
From source file:com.nononsenseapps.notepad.ActivityMain.java
/** * Opens the specified list and closes the left drawer *///from w ww .j a v a 2 s .c o m void openList(final long id) { // Open list Intent i = new Intent(ActivityMain.this, ActivityMain_.class); i.setAction(Intent.ACTION_VIEW).setData(TaskList.getUri(id)).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); // If editor is on screen, we need to reload fragments if (listOpener == null) { while (getSupportFragmentManager().popBackStackImmediate()) { // Need to pop the entire stack and then load } reverseAnimation = true; startActivity(i); } else { // If not popped, then send the call to the fragment // directly Log.d("nononsenseapps list", "calling listOpener"); listOpener.openList(id); } // And then close drawer if (drawerLayout != null && leftDrawer != null) { drawerLayout.closeDrawer(leftDrawer); } }
From source file:es.ugr.swad.swadroid.modules.notifications.Notifications.java
@Override protected void postConnect() { Notification notif;// w w w. j a va 2s . c o m Intent notificationIntent = new Intent(this, Notifications.class); PendingIntent pendingIntent; notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); //single top to avoid creating many activity stacks queue notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); pendingIntent = PendingIntent.getActivity(getApplicationContext(), 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT); if (!SyncUtils.isSyncAutomatically(getApplicationContext())) { if (notifCount > 0) { notif = AlertNotificationFactory.createAlertNotification(getApplicationContext(), getString(R.string.app_name), notifCount + " " + getString(R.string.notificationsAlertMsg), getString(R.string.app_name), pendingIntent, R.drawable.ic_launcher_swadroid_notif, R.drawable.ic_launcher_swadroid, true, true, false, false); AlertNotificationFactory.showAlertNotification(getApplicationContext(), notif, NOTIF_ALERT_ID); } else { Toast.makeText(this, R.string.NoNotificationsMsg, Toast.LENGTH_LONG).show(); } // Sends to SWAD the "seen notifications" info sendReadedNotifications(); refreshScreen(); } }
From source file:cz.tsystems.portablecheckin.MainActivity.java
@Override public void onActivityCreated(Bundle savedInstanceState) { app = (PortableCheckin) getActivity().getApplicationContext(); if (PortableCheckin.user != null) { setClickLiseners();// w w w. j a va2s. c o m if (spScenare.getAdapter() == null) setScenareSpinner(); setPalivoSpinner(); // setBrandImage(); } else { Intent i = new Intent(getActivity(), LoginActivity.class); i.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(i); } super.onActivityCreated(savedInstanceState); }
From source file:me.willowcheng.makerthings.ui.OpenHABMainActivity.java
@Override public void onResume() { Log.d(TAG, "onResume()"); super.onResume(); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, ((Object) this).getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); if (NfcAdapter.getDefaultAdapter(this) != null) NfcAdapter.getDefaultAdapter(this).enableForegroundDispatch(this, pendingIntent, null, null); if (!TextUtils.isEmpty(mNfcData)) { Log.d(TAG, "We have NFC data from launch"); }/*from w w w. j ava 2 s. c om*/ pagerAdapter.setColumnsNumber(getResources().getInteger(R.integer.pager_columns)); FragmentManager fm = getSupportFragmentManager(); stateFragment = (StateRetainFragment) fm.findFragmentByTag("stateFragment"); // If state fragment doesn't exist (which means fresh start of the app) // or if state fragment returned 0 fragments (this happens sometimes and we don't yet // know why, so this is a workaround // start over the whole process if (stateFragment == null || stateFragment.getFragmentList().size() == 0) { stateFragment = null; stateFragment = new StateRetainFragment(); fm.beginTransaction().add(stateFragment, "stateFragment").commit(); mOpenHABTracker = new OpenHABTracker(this, openHABServiceType, mServiceDiscoveryEnabled); mStartedWithNetworkConnectivityInfo = NetworkConnectivityInfo.currentNetworkConnectivityInfo(this); mOpenHABTracker.start(); // If state fragment exists and contains something then just restore the fragments } else { Log.d(TAG, "State fragment found"); // If connectivity type changed while we were in background // Restart the whole process // TODO: this must be refactored to remove duplicate code! if (!NetworkConnectivityInfo.currentNetworkConnectivityInfo(this) .equals(mStartedWithNetworkConnectivityInfo)) { Log.d(TAG, "Connectivity type changed while I was out, or zero fragments found, need to restart"); // Clean up any existing fragments pagerAdapter.clearFragmentList(); stateFragment.getFragmentList().clear(); stateFragment = null; // Clean up title this.setTitle(R.string.app_name); stateFragment = new StateRetainFragment(); fm.beginTransaction().add(stateFragment, "stateFragment").commit(); mOpenHABTracker = new OpenHABTracker(this, openHABServiceType, mServiceDiscoveryEnabled); mStartedWithNetworkConnectivityInfo = NetworkConnectivityInfo.currentNetworkConnectivityInfo(this); mOpenHABTracker.start(); return; } pagerAdapter.setFragmentList(stateFragment.getFragmentList()); Log.d(TAG, String.format("Loaded %d fragments", stateFragment.getFragmentList().size())); pager.setCurrentItem(stateFragment.getCurrentPage()); Log.d(TAG, String.format("Loaded current page = %d", stateFragment.getCurrentPage())); } if (!TextUtils.isEmpty(mPendingNfcPage)) { openNFCPageIfPending(); } checkFullscreen(); }