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.example.android.supportv4.media.MediaNotificationManager.java
private PendingIntent createContentIntent() { Intent openUI = new Intent(mService, MediaBrowserSupport.class); openUI.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); return PendingIntent.getActivity(mService, REQUEST_CODE, openUI, PendingIntent.FLAG_CANCEL_CURRENT); }
From source file:com.jmstudios.redmoon.presenter.ScreenFilterPresenter.java
private void refreshForegroundNotification() { if (isOff()) { return;//from w w w . j a v a2s. c o m } Context context = mView.getContext(); ProfilesModel profilesModel = new ProfilesModel(context); String title = context.getString(R.string.app_name); int color = context.getResources().getColor(R.color.color_primary); Intent offCommand = mFilterCommandFactory.createCommand(ScreenFilterService.COMMAND_OFF); int smallIconResId = R.drawable.notification_icon_half_moon; String contentText; int pauseOrResumeDrawableResId; Intent pauseOrResumeCommand; String pauseOrResumeActionText; if (isPaused()) { Log.d(TAG, "Creating notification while in pause state"); contentText = context.getString(R.string.paused); pauseOrResumeDrawableResId = R.drawable.ic_play; pauseOrResumeCommand = mFilterCommandFactory.createCommand(ScreenFilterService.COMMAND_ON); pauseOrResumeActionText = context.getString(R.string.resume_action); } else { Log.d(TAG, "Creating notification while NOT in pause state"); contentText = context.getString(R.string.running); pauseOrResumeDrawableResId = R.drawable.ic_pause; pauseOrResumeCommand = mFilterCommandFactory.createCommand(ScreenFilterService.COMMAND_PAUSE); pauseOrResumeActionText = context.getString(R.string.pause_action); } Intent shadesActivityIntent = new Intent(context, ShadesActivity.class); shadesActivityIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent pauseOrResumePI = PendingIntent.getService(context, REQUEST_CODE_ACTION_PAUSE_OR_RESUME, pauseOrResumeCommand, PendingIntent.FLAG_UPDATE_CURRENT); PendingIntent settingsPI = PendingIntent.getActivity(context, REQUEST_CODE_ACTION_SETTINGS, shadesActivityIntent, PendingIntent.FLAG_UPDATE_CURRENT); Intent nextProfileIntent = new Intent(context, NextProfileCommandReceiver.class); PendingIntent nextProfilePI = PendingIntent.getBroadcast(context, REQUEST_CODE_NEXT_PROFILE, nextProfileIntent, 0); mNotificationBuilder = new NotificationCompat.Builder(mContext); mNotificationBuilder.setSmallIcon(smallIconResId).setContentTitle(title).setContentText(contentText) .setColor(color).setContentIntent(settingsPI) .addAction(pauseOrResumeDrawableResId, pauseOrResumeActionText, pauseOrResumePI) .addAction(R.drawable.ic_next_profile, ProfilesHelper.getProfileName(profilesModel, mSettingsModel.getProfile(), context), nextProfilePI) .setPriority(Notification.PRIORITY_MIN); if (isPaused()) { Log.d(TAG, "Creating a dismissible notification"); NotificationManager mNotificationManager = (NotificationManager) mContext .getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.notify(NOTIFICATION_ID, mNotificationBuilder.build()); } else { Log.d(TAG, "Creating a persistent notification"); mServiceController.startForeground(NOTIFICATION_ID, mNotificationBuilder.build()); } }
From source file:com.veniosg.dir.android.fragment.SearchListFragment.java
private void browse(FileHolder file) { if (file.getFile().isDirectory()) { Intent intent = new Intent(getActivity(), FileManagerActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.setData(Uri.parse(file.getFile().getAbsolutePath())); startActivity(intent);//from w ww .j a v a 2 s . c o m } else { openFile(file, getContext()); } }
From source file:com.example.android.mediabrowserservice.MediaNotificationManager.java
private PendingIntent createContentIntent() { Intent openUI = new Intent(mService, MusicPlayerActivity.class); openUI.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); return PendingIntent.getActivity(mService, REQUEST_CODE, openUI, PendingIntent.FLAG_CANCEL_CURRENT); }
From source file:com.sigilance.CardEdit.MainActivity.java
/** * Receive new NFC Intents to this activity only by enabling foreground dispatch. * This can only be done in onResume!// w w w.j a va2 s . c o m */ public void enableNfcForegroundDispatch() { mNfcAdapter = NfcAdapter.getDefaultAdapter(this); if (mNfcAdapter == null) { return; } Intent nfcI = new Intent(this, getClass()) .addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent nfcPendingIntent = PendingIntent.getActivity(this, 0, nfcI, PendingIntent.FLAG_CANCEL_CURRENT); IntentFilter[] writeTagFilters = new IntentFilter[] { new IntentFilter(NfcAdapter.ACTION_TAG_DISCOVERED) }; try { mNfcAdapter.enableForegroundDispatch(this, nfcPendingIntent, writeTagFilters, null); } catch (IllegalStateException e) { Toast.makeText(this, "NfcForegroundDispatch Error!", Toast.LENGTH_LONG).show(); } }
From source file:com.arisprung.tailgate.GCMIntentService.java
/** * Issues a notification to inform the user that server has sent a message. *//*from w w w .jav a 2 s . c o m*/ private static void generateNotification(Context context, MessageBean message) { // Intent notificationIntent = new Intent(ctx, MainActivity.class); // PendingIntent contentIntent = PendingIntent.getActivity(ctx, // 10, notificationIntent, // PendingIntent.FLAG_CANCEL_CURRENT); // // NotificationManager nm = (NotificationManager) ctx // .getSystemService(Context.NOTIFICATION_SERVICE); // // Resources res = ctx.getResources(); // Notification.Builder builder = new Notification.Builder(ctx); // // Bitmap profile = TailGateUtility.getUserPic(message.getFaceID()); // // builder.setContentIntent(contentIntent) // .setSmallIcon(R.drawable.ic_launcher) // .setLargeIcon(profile) // .setTicker(res.getString(R.string.app_name)) // .setWhen(System.currentTimeMillis()) // .setAutoCancel(true) // .setContentTitle(message.getUserName()) // .setContentText(message.getMessage()); // Notification n = builder.build(); // // nm.notify(0, n); int icon = R.drawable.fanatic_icon_72px; long when = System.currentTimeMillis(); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new Notification(icon, message.getMessage(), when); String name = message.getUserName(); Intent notificationIntent = new Intent(context, MainActivity.class); // set intent so it does not start a new activity notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, 0); notification.setLatestEventInfo(context, name, message.getMessage(), intent); notification.flags |= Notification.FLAG_AUTO_CANCEL; notificationManager.notify(0, notification); }
From source file:com.wolkabout.hexiwear.activity.MainActivity.java
private void onBonded(BluetoothDevice device) { Log.i(TAG, "Successfully bonded to: " + device.getName()); if (!devicesStore.isRegistered(device)) { deviceRegistrationService.registerHexiwearDevice(device); } else if (device.getName().contains(OTAP_PREFIX)) { FirmwareSelectActivity_.intent(this).device(device).start(); } else {//from ww w .ja va 2 s . c om ReadingsActivity_.intent(this).flags(Intent.FLAG_ACTIVITY_SINGLE_TOP).device(device).start(); } }
From source file:kashmirr.social.service.NotificationService.java
private void sendLocationRequestNotification(Context context, String requestId, String requesterName) { NotificationManager notificationManagerCompat = (NotificationManager) context .getSystemService(NOTIFICATION_SERVICE); Intent requestsViewIntent = new Intent(context, RequestsView.class); requestsViewIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent requestsViewPending = PendingIntent.getActivity(context, Integer.valueOf(requestId), requestsViewIntent, 0);//from w w w .j ava 2s .c o m android.support.v7.app.NotificationCompat.Builder builder = new android.support.v7.app.NotificationCompat.Builder( context); builder.setSmallIcon(R.drawable.location_vector); builder.setAutoCancel(true); builder.setContentTitle(requesterName + " " + getString(R.string.requestedShareLocation)); builder.setContentText(getString(R.string.requestedTextBody)); builder.setGroup(GROUP_KEY_MESSAGES); builder.setDefaults(android.app.Notification.DEFAULT_ALL); builder.setContentIntent(requestsViewPending); builder.setStyle(new NotificationCompat.BigTextStyle().bigText(getString(R.string.toViewTheRequest))); builder.setShowWhen(true); android.app.Notification notification = builder.build(); notificationManagerCompat.notify(Integer.valueOf(requestId), notification); }
From source file:com.microsoft.rightsmanagement.ui.PolicyPickerActivity.java
/** * Show UI.//from w w w .j av a2s . c o m * * @param requestCode the request code * @param parentActivity the activity * @param templateDescriptorList the template descriptor list * @param originalTemplateDescriptor the original template descriptor * @param pickerCompletionCallback the picker completion callback */ public static void show(int requestCode, Activity parentActivity, List<TemplateDescriptor> templateDescriptorList, TemplateDescriptor originalTemplateDescriptor, CompletionCallback<PolicyPickerActivityResult> pickerCompletionCallback) { Logger.ms(TAG, "show"); parentActivity = validateActivityInputParameter(parentActivity); templateDescriptorList = validateTemplateDescriptorListInputParameter(templateDescriptorList); pickerCompletionCallback = validateCompletionCallbackInputParameter(pickerCompletionCallback); int requestCallbackId = pickerCompletionCallback.hashCode(); TemplateDescriptor[] templateDescriptorArray = new TemplateDescriptor[templateDescriptorList.size()]; templateDescriptorList.toArray(templateDescriptorArray); // fill the array sCallbackManager.putWaitingRequest(requestCallbackId, pickerCompletionCallback, templateDescriptorArray); Intent intent = new Intent(parentActivity, PolicyPickerActivity.class); // translate MSIPC SDK object model to UI model TemplateDescriptorModel[] templateDescriptorItemArray = TemplateDescriptorModel .create(templateDescriptorArray); TemplateDescriptorModel originalTemplateDescriptorItem = null; if (originalTemplateDescriptor != null) { originalTemplateDescriptorItem = new TemplateDescriptorModel(originalTemplateDescriptor); } // start activity intent.putExtra(REQUEST_CALLBACK_ID, requestCallbackId); intent.putExtra(REQUEST_TEMPLATE_DESCRIPTOR_ITEM_ARRAY, templateDescriptorItemArray); intent.putExtra(REQUEST_ORIGINAL_TEMPLATE_DESCRIPTOR_ITEM, originalTemplateDescriptorItem); intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); parentActivity.startActivityForResult(intent, requestCode); Logger.me(TAG, "show"); }