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:com.aqnote.app.wifianalyzer.MainActivity.java
private void reloadActivity() { finish();/* w w w . j a v a2 s. c om*/ Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); }
From source file:com.agna.setmaster.ui.screen.profile.ProfileActivity.java
public static void start(Activity activity, Profile profile) { Intent i = new Intent(activity, ProfileActivity.class); i.putExtra(EXTRA_PROFILE, profile);/*ww w . j a v a2 s .co m*/ i.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); activity.startActivity(i); }
From source file:edu.cmu.mpcs.dashboard.TagViewer.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // setContentView(R.layout.tag_viewer); mNfcAdapter = NfcAdapter.getDefaultAdapter(this); Intent intent = this.getIntent(); writeContent = intent.getStringExtra("writeContent"); mLoginButton = new LoginButton(getApplicationContext()); // if(flag == true) Log.d("TAG_VIEWER", "writeConent:" + writeContent); // setContentView(R.layout.tag_viewer); mNfcPendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); // mTagContent = (LinearLayout) findViewById(R.id.list); // mTitle = (TextView) findViewById(R.id.title); Log.d("TAG_VIEWER", "Utility.mFacebook is " + Utility.mFacebook); if (Utility.mFacebook == null) { InitializeLogin = true;//from www . j a v a2 s .co m } // Create the Facebook Object using the app id. edu.cmu.mpcs.dashboard.Utility.mFacebook = new Facebook(APP_ID); // Instantiate the asynrunner object for asynchronous api calls. edu.cmu.mpcs.dashboard.Utility.mAsyncRunner = new AsyncFacebookRunner( edu.cmu.mpcs.dashboard.Utility.mFacebook); Log.d("TAG_VIEWER", "in oncreate in TagViewer is session valid?:" + Utility.mFacebook.isSessionValid()); mLoginButton.init(this, AUTHORIZE_ACTIVITY_RESULT_CODE, Utility.mFacebook, permissions); if (APP_ID == null) { Util.showAlert(this, "Warning", "Facebook Applicaton ID must be " + "specified before running this example: see FbAPIs.java"); return; } SessionStore.restore(Utility.mFacebook, this); SessionEvents.addAuthListener(new FbAPIsAuthListener()); SessionEvents.addLogoutListener(new FbAPIsLogoutListener()); // SessionEvents.r if (Utility.mFacebook.isSessionValid()) { requestUserData(); } // TODO do something about - dont call resolve intent by // default. if (writeContent == null && NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction())) { Log.d("TAG_VIEWER", "in OnCreate Before reading"); loginIntent = intent; if (InitializeLogin) { /* * This is if we come to tag viewer without * having started dashboard activity */ mLoginButton.initializeFbLogin(); } else { /* This is we if read the tag while in dashboard! */ resolveIntent(intent); } // mLoginButton.performLogout(); } else { Log.d("TAG_VIEWER", "Before creating alert dialog"); builder = new AlertDialog.Builder(TagViewer.this); dialog = builder.create(); builder.setTitle("Touch tag to write").setOnCancelListener(new DialogInterface.OnCancelListener() { public void onCancel(DialogInterface dialog) { Log.d("TAG_VIEWER", "On cancel called"); disableTagWriteMode(); } }).create(); dialog.setTitle("touch tag to write"); dialog.show(); dialog.setOnDismissListener(new OnDismissListener() { public void onDismiss(DialogInterface dialog) { // TODO Auto-generated method stub Log.d("TAG_VIEWER", "On dismiss called"); disableTagWriteMode(); } }); // builder.setCancelable(true); // builder.setOnCancelListener(new // DialogInterface.OnCancelListener() { // public void onCancel(DialogInterface dialog) { // Log.d("TAG_VIEWER","On cancel called"); // disableTagWriteMode(); // // } // }).create().show(); } // Tag writing mode if (writeContent != null && NfcAdapter.ACTION_NDEF_DISCOVERED.equals(intent.getAction())) { Log.d("TAG_VIEWER", "in Oncreate Before writing"); Tag detectedTag = intent.getParcelableExtra(NfcAdapter.EXTRA_TAG); try { WriteToTag.write(detectedTag, writeContent); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (FormatException e) { // TODO Auto-generated catch block e.printStackTrace(); } Log.d("TAG_VIEWER", "in on create, writing to tag"); } Log.d("TAG_VIEWER", "in create"); }
From source file:com.example.domiter.fileexplorer.fragment.SearchListFragment.java
private void browse(Uri path) { Intent intent = new Intent(getActivity(), FileManagerActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.setData(path);// w ww.j a v a 2 s .c o m startActivity(intent); }
From source file:com.syncedsynapse.kore2.ui.MusicActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_show_remote: // Starts remote Intent launchIntent = new Intent(this, RemoteActivity.class).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); startActivity(launchIntent);/*from ww w .ja v a 2 s . co m*/ return true; case android.R.id.home: // Only respond to this if we are showing some details, which can be checked by // checking if some id != -1, in which case we should go back to the previous // fragment, which is the list. // The default behaviour is handled by the nav drawer (open/close) if (selectedAlbumId != -1) { selectedAlbumId = -1; selectedAlbumTitle = null; setupActionBar(null, selectedArtistName, selectedGenreTitle, selectedMusicVideoTitle); getSupportFragmentManager().popBackStack(); return true; } else if (selectedArtistId != -1) { selectedArtistId = -1; selectedArtistName = null; setupActionBar(selectedAlbumTitle, null, selectedGenreTitle, selectedMusicVideoTitle); getSupportFragmentManager().popBackStack(); return true; } else if (selectedGenreId != -1) { selectedGenreId = -1; selectedGenreTitle = null; setupActionBar(selectedAlbumTitle, selectedArtistName, null, selectedMusicVideoTitle); getSupportFragmentManager().popBackStack(); return true; } else if (selectedMusicVideoId != -1) { selectedMusicVideoId = -1; selectedMusicVideoTitle = null; setupActionBar(selectedAlbumTitle, selectedArtistName, selectedGenreTitle, null); getSupportFragmentManager().popBackStack(); return true; } break; default: break; } return super.onOptionsItemSelected(item); }
From source file:com.android.contacts.activities.ContactDetailActivity.java
/** @} */ @Override/*w ww . j a v a 2s.c om*/ protected void onCreate(Bundle savedState) { super.onCreate(savedState); LogUtils.i(TAG, "[onCreate][launch]start"); ///M: Bug Fix for ALPS01022809,JE happens when click the favourite video to choose contact in tablet registerPHBReceiver(); mIsActivitFinished = false; /** M: Bug Fix for ALPS00393950 @{ */ boolean isUsingTwoPanes = PhoneCapabilityTester.isUsingTwoPanes(this); if (!isUsingTwoPanes) { SetIndicatorUtils.getInstance().registerReceiver(this); } /** @} */ if (PhoneCapabilityTester.isUsingTwoPanes(this)) { // This activity must not be shown. We have to select the contact in the // PeopleActivity instead ==> Create a forward intent and finish final Intent originalIntent = getIntent(); Intent intent = new Intent(); intent.setAction(originalIntent.getAction()); intent.setDataAndType(originalIntent.getData(), originalIntent.getType()); // If we are launched from the outside, we should create a new task, because the user // can freely navigate the app (this is different from phones, where only the UP button // kicks the user into the full app) if (shouldUpRecreateTask(intent)) { intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); } else { intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | Intent.FLAG_ACTIVITY_FORWARD_RESULT | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); } intent.setClass(this, PeopleActivity.class); startActivity(intent); LogUtils.i(TAG, "onCreate(),Using Two Panes...finish Actiivity.."); finish(); return; } setContentView(R.layout.contact_detail_activity); mContactDetailLayoutController = new ContactDetailLayoutController(this, savedState, getFragmentManager(), null, findViewById(R.id.contact_detail_container), mContactDetailFragmentListener); // We want the UP affordance but no app icon. // Setting HOME_AS_UP, SHOW_TITLE and clearing SHOW_HOME does the trick. ActionBar actionBar = getActionBar(); if (actionBar != null) { ///@Modify for add Customer view{ actionBar.setDisplayOptions( ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_CUSTOM, ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_CUSTOM); ///@} actionBar.setTitle(""); } Log.i(TAG, getIntent().getData().toString()); /** M: New Feature xxx @{ */ //M:fix CR:ALPS00958663,disconnect to smartbook when contact screen happen JE if (getIntent() != null && getIntent().getData() != null) { mSimOrPhoneUri = getIntent().getData(); Log.i(TAG, "mSimOrPhoneUri = " + mSimOrPhoneUri); } else { Log.e(TAG, "Get intent data error getIntent() = " + getIntent()); } /// M: @ CT contacts detail history set listener{ ExtensionManager.getInstance().getContactDetailEnhancementExtension().configActionBarExt(getActionBar(), ContactPluginDefault.COMMD_FOR_OP09); /// @} LogUtils.i(TAG, "[onCreate][launch]end"); }
From source file:io.atrac613.AbstractNfcTagFragment.java
@Override public void onResume() { Log.d(TAG, "*** AbstractNfcFeliCaTagFragment go Resume"); //foregrandDispathch Activity a = this.getActivity(); IntentFilter ndef = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED); IntentFilter tag = new IntentFilter(NfcAdapter.ACTION_TAG_DISCOVERED); IntentFilter tech = new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED); try {//from w ww . j ava 2 s. co m ndef.addDataType("*/*"); } catch (MalformedMimeTypeException e) { throw new RuntimeException("fail", e); } IntentFilter[] filters = new IntentFilter[] { ndef, tag, tech }; PendingIntent pendingIntent = PendingIntent.getActivity(a, 0, new Intent(a, a.getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); NfcAdapter adapter = NfcAdapter.getDefaultAdapter(this.getActivity()); adapter.enableForegroundDispatch(this.getActivity(), pendingIntent, filters, registerTechList(mTechList)); super.onResume(); }
From source file:com.morlunk.leeroy.LeeroyUpdateService.java
private void handleCheckUpdates(Intent intent, boolean notify, ResultReceiver receiver) { List<LeeroyApp> appList = LeeroyApp.getApps(getPackageManager()); if (appList.size() == 0) { return;/*from w ww . j av a2s . co m*/ } List<LeeroyAppUpdate> updates = new LinkedList<>(); List<LeeroyApp> notUpdatedApps = new LinkedList<>(); List<LeeroyException> exceptions = new LinkedList<>(); for (LeeroyApp app : appList) { try { String paramUrl = app.getJenkinsUrl() + "/api/json?tree=lastSuccessfulBuild[number,url]"; URL url = new URL(paramUrl); URLConnection conn = url.openConnection(); Reader reader = new InputStreamReader(conn.getInputStream()); JsonReader jsonReader = new JsonReader(reader); jsonReader.beginObject(); jsonReader.nextName(); jsonReader.beginObject(); int latestSuccessfulBuild = 0; String buildUrl = null; while (jsonReader.hasNext()) { String name = jsonReader.nextName(); if ("number".equals(name)) { latestSuccessfulBuild = jsonReader.nextInt(); } else if ("url".equals(name)) { buildUrl = jsonReader.nextString(); } else { throw new RuntimeException("Unknown key " + name); } } jsonReader.endObject(); jsonReader.endObject(); jsonReader.close(); if (latestSuccessfulBuild > app.getJenkinsBuild()) { LeeroyAppUpdate update = new LeeroyAppUpdate(); update.app = app; update.newBuild = latestSuccessfulBuild; update.newBuildUrl = buildUrl; updates.add(update); } else { notUpdatedApps.add(app); } } catch (MalformedURLException e) { e.printStackTrace(); CharSequence appName = app.getApplicationInfo().loadLabel(getPackageManager()); exceptions.add(new LeeroyException(app, getString(R.string.invalid_url, appName), e)); } catch (IOException e) { e.printStackTrace(); exceptions.add(new LeeroyException(app, e)); } } if (notify) { NotificationManagerCompat nm = NotificationManagerCompat.from(this); if (updates.size() > 0) { NotificationCompat.Builder ncb = new NotificationCompat.Builder(this); ncb.setSmallIcon(R.drawable.ic_stat_update); ncb.setTicker(getString(R.string.updates_available)); ncb.setContentTitle(getString(R.string.updates_available)); ncb.setContentText(getString(R.string.num_updates, updates.size())); ncb.setPriority(NotificationCompat.PRIORITY_LOW); ncb.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); Intent appIntent = new Intent(this, AppListActivity.class); appIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); ncb.setContentIntent( PendingIntent.getActivity(this, 0, appIntent, PendingIntent.FLAG_CANCEL_CURRENT)); ncb.setAutoCancel(true); NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle(); for (LeeroyAppUpdate update : updates) { CharSequence appName = update.app.getApplicationInfo().loadLabel(getPackageManager()); style.addLine(getString(R.string.notify_app_update, appName, update.app.getJenkinsBuild(), update.newBuild)); } style.setSummaryText(getString(R.string.app_name)); ncb.setStyle(style); ncb.setNumber(updates.size()); nm.notify(NOTIFICATION_UPDATE, ncb.build()); } if (exceptions.size() > 0) { NotificationCompat.Builder ncb = new NotificationCompat.Builder(this); ncb.setSmallIcon(R.drawable.ic_stat_error); ncb.setTicker(getString(R.string.error_checking_updates)); ncb.setContentTitle(getString(R.string.error_checking_updates)); ncb.setContentText(getString(R.string.click_to_retry)); ncb.setPriority(NotificationCompat.PRIORITY_LOW); ncb.setVisibility(NotificationCompat.VISIBILITY_PUBLIC); ncb.setContentIntent(PendingIntent.getService(this, 0, intent, PendingIntent.FLAG_CANCEL_CURRENT)); ncb.setAutoCancel(true); ncb.setNumber(exceptions.size()); nm.notify(NOTIFICATION_ERROR, ncb.build()); } } if (receiver != null) { Bundle results = new Bundle(); results.putParcelableArrayList(EXTRA_UPDATE_LIST, new ArrayList<>(updates)); results.putParcelableArrayList(EXTRA_NO_UPDATE_LIST, new ArrayList<>(notUpdatedApps)); results.putParcelableArrayList(EXTRA_EXCEPTION_LIST, new ArrayList<>(exceptions)); receiver.send(0, results); } }
From source file:com.amazon.cordova.plugin.ADMMessageHandler.java
/** * Creates a notification when app is not running or is not in foreground. It puts the message info into the Intent * extra/*from w w w. ja v a 2 s . c om*/ * * @param context * @param extras */ public void createNotification(Context context, Bundle extras) { NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); String appName = getAppName(this); // reuse the intent so that we can combine multiple messages into extra if (notificationIntent == null) { notificationIntent = new Intent(this, ADMHandlerActivity.class); } notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); notificationIntent.putExtra("pushBundle", extras); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); final Builder notificationBuilder = new Notification.Builder(context); notificationBuilder.setSmallIcon(context.getApplicationInfo().icon).setWhen(System.currentTimeMillis()) .setContentIntent(contentIntent); if (this.shouldShowMessageInNotification()) { String message = extras.getString(PushPlugin.MESSAGE); notificationBuilder.setContentText(Html.fromHtml(message).toString()); } else { notificationBuilder.setContentText(this.defaultMessageTextInNotification()); } String title = appName; notificationBuilder.setContentTitle(title).setTicker(title); notificationBuilder.setAutoCancel(true); // Because the ID remains unchanged, the existing notification is updated. notificationManager.notify((String) appName, NOTIFICATION_ID, notificationBuilder.getNotification()); }