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.roamprocess1.roaming4world.service.SipNotifications.java
public synchronized void notifyRegisteredAccounts(ArrayList<SipProfileState> activeAccountsInfos, boolean showNumbers) { if (!isServiceWrapper) { Log.e(THIS_FILE, "Trying to create a service notification from outside the service"); System.out.println("SipNotifications class notifyRegisteredAccounts"); return;/*from www.j a v a 2s. c o m*/ } int icon = R.drawable.ic_stat_sipok; CharSequence tickerText = context.getString(R.string.service_ticker_registered_text); long when = System.currentTimeMillis(); System.out.println("SipNotification synchronized"); Builder nb = new NotificationCompat.Builder(context); nb.setSmallIcon(icon); nb.setTicker(tickerText); nb.setWhen(when); //Intent notificationIntent = new Intent(SipManager.ACTION_SIP_DIALER); Intent notificationIntent = new Intent("com.roamprocess1.roaming4world.R4wHome.R4w_ACTIVITY"); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); System.out.println("SipNitification synchronized 1"); PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0); System.out.println("SipNitification synchronized 2"); RegistrationNotification contentView = new RegistrationNotification(context.getPackageName()); contentView.clearRegistrations(); if (!Compatibility.isCompatible(9)) { contentView.setTextsColor(notificationPrimaryTextColor); } contentView.addAccountInfos(context, activeAccountsInfos); // notification.setLatestEventInfo(context, contentTitle, // contentText, contentIntent); nb.setOngoing(true); nb.setOnlyAlertOnce(true); nb.setContentIntent(contentIntent); nb.setContent(contentView); Notification notification = nb.build(); notification.flags |= Notification.FLAG_NO_CLEAR; // We have to re-write content view because getNotification setLatestEventInfo implicitly notification.contentView = contentView; if (showNumbers) { // This only affects android 2.3 and lower notification.number = activeAccountsInfos.size(); } startForegroundCompat(REGISTER_NOTIF_ID, notification); }
From source file:org.awesomeapp.messenger.service.StatusBarNotifier.java
private void notify(String sender, String title, String tickerText, String message, long providerId, long accountId, Intent intent, boolean lightWeightNotify, int iconSmall, Bitmap iconLarge) { intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); NotificationInfo info;//from w w w . j a va 2 s . co m synchronized (mNotificationInfos) { info = mNotificationInfos.get(sender); if (info == null) { info = new NotificationInfo(providerId, accountId); mNotificationInfos.put(sender, info); } info.addItem(sender, title, message, intent); } mNotificationManager.notify(info.computeNotificationId(), info.createNotification(tickerText, lightWeightNotify, iconSmall, iconLarge, intent)); }
From source file:com.dm.wallpaper.board.fragments.CollectionFragment.java
private void initSearchBar() { Drawable drawable = ConfigurationHelper.getNavigationIcon(getActivity(), WallpaperBoardApplication.getConfig().getNavigationIcon()); int color = ColorHelper.getAttributeColor(getActivity(), R.attr.search_bar_icon); if (drawable != null) { mNavigation.setImageDrawable(DrawableHelper.getTintedDrawable(drawable, color)); }/*from w w w .j a v a 2s . com*/ mNavigation.setOnClickListener(view -> { if (getActivity() instanceof WallpaperBoardActivity) { ((WallpaperBoardActivity) getActivity()).openDrawer(); } }); ImageView searchIcon = getActivity().findViewById(R.id.search); if (searchIcon != null) { searchIcon.setImageDrawable( DrawableHelper.getTintedDrawable(getActivity(), R.drawable.ic_toolbar_search, color)); } TextView searchBarTitle = getActivity().findViewById(R.id.search_bar_title); if (searchBarTitle != null) { if (WallpaperBoardApplication.getConfig().getAppLogoColor() != -1) { searchBarTitle.setTextColor(WallpaperBoardApplication.getConfig().getAppLogoColor()); } else { searchBarTitle.setTextColor(ColorHelper.setColorAlpha(color, 0.7f)); } } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (mSearchBar.getLayoutParams() instanceof CoordinatorLayout.LayoutParams) { CoordinatorLayout.LayoutParams params = (CoordinatorLayout.LayoutParams) mSearchBar .getLayoutParams(); params.setMargins(params.leftMargin, params.topMargin + WindowHelper.getStatusBarHeight(getActivity()), params.leftMargin, params.bottomMargin); } StateListAnimator stateListAnimator = AnimatorInflater.loadStateListAnimator(getActivity(), R.animator.card_lift); mSearchBar.setStateListAnimator(stateListAnimator); } mSearchBar.setOnClickListener(view -> { Intent intent = new Intent(getActivity(), WallpaperBoardBrowserActivity.class); intent.putExtra(Extras.EXTRA_FRAGMENT_ID, Extras.ID_WALLPAPER_SEARCH); intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); getActivity().overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out); }); mMenuSort.setImageDrawable( DrawableHelper.getTintedDrawable(getActivity(), R.drawable.ic_toolbar_sort, color)); mMenuSort.setOnClickListener(view -> { Popup.Builder(getActivity()).to(mMenuSort).list(PopupItem.getSortItems(getActivity(), true)) .callback((popup, position) -> { Preferences.get(getActivity()).setSortBy(popup.getItems().get(position).getType()); refreshWallpapers(); popup.dismiss(); }).show(); }); }
From source file:com.mobileman.moments.android.frontend.activity.IncomingCallActivity.java
private void sendNotificationAndFinish() { if (streamingUser != null) { Intent intent = new Intent(getApplicationContext(), MediaPlayerActivity.class); Bundle extras = new Bundle(); extras.putString(MediaPlayerActivity.MEDIA_URL, streamingUser.getStream().getFullVideoUrl()); extras.putString(MediaPlayerActivity.THUMBNAIL_URL, streamingUser.getStream().getFullThumbnailUrl()); extras.putString(MediaPlayerActivity.USER_ID, streamingUser.getUuid()); intent.putExtras(extras);/*from w w w . j a v a 2 s .c o m*/ intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent contentIntent = PendingIntent.getActivity(getApplicationContext(), 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder b = new NotificationCompat.Builder(getApplicationContext()); String notificationTitle = userName + " " + getResources().getString(R.string.isLiveSuffix); String notificationText = "";// getResources().getString(R.string.missedCallNotification) + " " + streamingUser.getName(); String mediaUrl = streamingUser.getStream().getFullVideoUrl(); if ((streamingUser.getStream() != null) && (streamingUser.getStream().getTitle() != null)) { notificationText = streamingUser.getStream().getTitle(); //notificationText + "(" + streamingUser.getStream().getTitle() + ")"; } ImageView incomingCallUserImageView = (ImageView) findViewById(R.id.incomingCallUserImageView); Bitmap bitmap = ((BitmapDrawable) incomingCallUserImageView.getDrawable()).getBitmap(); NotificationCompat.BigTextStyle bigTextStyle = new NotificationCompat.BigTextStyle(); b.setAutoCancel(true).setSmallIcon(R.drawable.ic_launcher).setDefaults(Notification.DEFAULT_ALL) .setWhen(System.currentTimeMillis()).setTicker("X").setContentTitle(notificationTitle) .setContentText(notificationText) .setDefaults(Notification.DEFAULT_LIGHTS | Notification.DEFAULT_SOUND) .setContentIntent(contentIntent); // if (bitmap != null) { // b.setLargeIcon(bitmap); // } NotificationManager notificationManager = (NotificationManager) getApplicationContext() .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(++NOTIFICATION_COUNTER, b.build()); } finish(); }
From source file:com.weddingsingers.wsapp.fcm.MyFirebaseMessagingService.java
private void sendNotification(Alarm alarm, String action) { Intent intent = new Intent(this, SplashActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.putExtra(SplashActivity.EXTRA_FRAGNAME, ChattingActivity.class); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.manifest_ic_wedding_singers_512).setContentTitle("FCM Message") .setContentText(alarm.getMessage()).setAutoCancel(true).setSound(defaultSoundUri) .setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:com.googlecode.android_scripting.facade.ui.NFCBeamTask.java
@SuppressLint("NewApi") public void launchNFC() { Log.d(TAG, "launchNFC:" + beamStat); if (beamStat == 0) { _nfcAdapter.setNdefPushMessageCallback(this, getActivity()); _nfcAdapter.setOnNdefPushCompleteCallback(this, getActivity()); // start NFC Connection /*_nfcPendingIntent = PendingIntent.getActivity(getActivity().getApplicationContext(), 0, new Intent(getActivity().getApplicationContext(), FutureActivity.class) .addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); //from ww w .java2 s .c o m IntentFilter ndefDetected = new IntentFilter( NfcAdapter.ACTION_NDEF_DISCOVERED); try { ndefDetected.addDataType("application/com.hipipal.qpy.nfc"); } catch (MalformedMimeTypeException e) { throw new RuntimeException("Could not add MIME type.", e); } _readTagFilters = new IntentFilter[] { ndefDetected };*/ } else if (beamStat == 1) { //_nfcAdapter.setNdefPushMessageCallback(this, getActivity()); //_nfcAdapter.setOnNdefPushCompleteCallback(this, getActivity()); // start NFC Connection _nfcPendingIntent = PendingIntent.getActivity(getActivity().getApplicationContext(), 0, new Intent(getActivity().getApplicationContext(), FutureActivity.class) .addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); IntentFilter ndefDetected = new IntentFilter(NfcAdapter.ACTION_NDEF_DISCOVERED); try { ndefDetected.addDataType("application/com.hipipal.qpy.nfc"); } catch (MalformedMimeTypeException e) { throw new RuntimeException("Could not add MIME type.", e); } _readTagFilters = new IntentFilter[] { ndefDetected }; } }
From source file:com.airbop.client.GCMIntentService.java
private static void generateImageNotification(Context context, String title, String message, String url, String image_url, String large_icon) { // The bitmap to download Bitmap message_bitmap = null;/*from www .j a va 2 s .c o m*/ // Should we download the image? if ((image_url != null) && (!image_url.equals(""))) { message_bitmap = AirBopImageDownloader.downloadBitmap(image_url); } // If we didn't get the image, we're out of here if (message_bitmap == null) { generateNotification(context, title, message, url, large_icon); return; } int icon = R.drawable.ic_stat_gcm; long when = System.currentTimeMillis(); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); if ((title == null) || (title.equals(""))) { title = context.getString(R.string.app_name); } Intent notificationIntent = null; if ((url == null) || (url.equals(""))) { //just bring up the app notificationIntent = new Intent(context, DemoActivity.class); } else { //Launch the URL notificationIntent = new Intent(Intent.ACTION_VIEW); notificationIntent.setData(Uri.parse(url)); notificationIntent.addCategory(Intent.CATEGORY_BROWSABLE); } // 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 notification = new NotificationCompat.Builder(context).setContentTitle(title) .setContentText(message).setContentIntent(intent).setSmallIcon(icon) .setLargeIcon(decodeImage(large_icon)).setWhen(when) .setStyle(new NotificationCompat.BigPictureStyle().bigPicture(message_bitmap)).build(); notification.flags |= Notification.FLAG_AUTO_CANCEL; notificationManager.notify(0, notification); }
From source file:im.vector.receiver.VectorUniversalLinkReceiver.java
/** * Start the universal link to process to manage member details activity * * @param aContext the context./* www . ja v a 2s. c o m*/ */ private void manageMemberDetailsActivity(final Context aContext) { Log.d(LOG_TAG, "## manageMemberDetailsActivity() : open " + mParameters.get(ULINK_MATRIX_USER_ID_KEY) + " page"); final Activity currentActivity = VectorApp.getCurrentActivity(); if (null != currentActivity) { Intent startRoomInfoIntent = new Intent(currentActivity, VectorMemberDetailsActivity.class); startRoomInfoIntent.putExtra(VectorMemberDetailsActivity.EXTRA_MEMBER_ID, mParameters.get(ULINK_MATRIX_USER_ID_KEY)); startRoomInfoIntent.putExtra(VectorMemberDetailsActivity.EXTRA_MATRIX_ID, mSession.getCredentials().userId); currentActivity.startActivity(startRoomInfoIntent); } else { // clear the activity stack to home activity Intent intent = new Intent(aContext, VectorHomeActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra(VectorHomeActivity.EXTRA_MEMBER_ID, mParameters.get(ULINK_MATRIX_USER_ID_KEY)); aContext.startActivity(intent); } }
From source file:co.tinode.tindroid.ContactsFragment.java
private void handleItemClick(final ContactsAdapter.ViewHolder tag) { boolean done = false; if (mPhEmImData != null) { Utils.ContactHolder holder = mPhEmImData.get(tag.contact_id); if (holder != null) { String address = holder.getIm(); if (address != null) { Intent it = new Intent(getActivity(), MessageActivity.class); it.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP); it.putExtra("topic", address); startActivity(it);//from w w w. j a va 2 s . c o m done = true; } if (!done && ((address = holder.getPhone()) != null)) { // Send an SMS with an invitation Uri uri = Uri.fromParts("smsto", address, null); Intent it = new Intent(Intent.ACTION_SENDTO, uri); it.putExtra("sms_body", getString(R.string.tinode_invite_body)); startActivity(it); done = true; } if (!done && ((address = holder.getEmail()) != null)) { Uri uri = Uri.fromParts("mailto", address, null); Intent it = new Intent(Intent.ACTION_SENDTO, uri); it.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.tinode_invite_subject)); it.putExtra(Intent.EXTRA_TEXT, getString(R.string.tinode_invite_body)); startActivity(it); done = true; } } } if (!done) { Toast.makeText(getContext(), R.string.failed_to_invite, Toast.LENGTH_SHORT).show(); } }
From source file:me.trashout.service.TrashHunterService.java
private void createNotification(int trashCount, int trashHunterArea) { Log.d("TrashHunter", ".....createNotification..... trashHunterArea - " + trashHunterArea); Intent viewIntent = BaseActivity.generateIntent(this, TrashListFragment.class.getName(), TrashListFragment.generateBundle(true, trashHunterArea), MainActivity.class); viewIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); viewIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent viewPendingIntent = PendingIntent.getActivity(this, 0, viewIntent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT); Context context = getBaseContext(); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(context) .setSmallIcon(getNotificationIcon()) .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.mipmap.ic_launcher)) .setColor(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimary)) .setContentTitle(context.getString(R.string.app_name)) .setContentText(String.format(getString(R.string.notification_new_trash_formatter), trashCount)) .setAutoCancel(true).setContentIntent(viewPendingIntent); NotificationManager mNotificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Notification notif = mBuilder.build(); notif.defaults |= Notification.DEFAULT_SOUND; notif.defaults |= Notification.DEFAULT_VIBRATE; mNotificationManager.notify(NOTIFICATION_ID, notif); }