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.appdevper.mediaplayer.ui.PlaybackControlsFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_playback_controls, container, false); mPlayPause = (ImageButton) rootView.findViewById(R.id.play_pause); mPlayPause.setEnabled(true);/*from w w w. jav a 2 s . co m*/ mPlayPause.setOnClickListener(mButtonListener); mTitle = (TextView) rootView.findViewById(R.id.title); mSubtitle = (TextView) rootView.findViewById(R.id.artist); mExtraInfo = (TextView) rootView.findViewById(R.id.extra_info); mAlbumArt = (ImageView) rootView.findViewById(R.id.album_art); rootView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(getActivity(), FullScreenPlayerActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); MediaMetadataCompat metadata = ((FragmentActivity) getActivity()).getSupportMediaController() .getMetadata(); if (metadata != null) { intent.putExtra(MainActivity.EXTRA_CURRENT_MEDIA_DESCRIPTION, metadata.getDescription()); } getActivity().startActivity(intent); } }); return rootView; }
From source file:de.yazo_games.mensaguthaben.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Log.i(TAG, "activity started"); FragmentManager fm = getSupportFragmentManager(); valueFragment = (ValueFragment) fm.findFragmentByTag(VALUE_TAG); if (valueFragment == null) { valueFragment = new ValueFragment(); }/* ww w . j a v a 2 s. c o m*/ fm.beginTransaction().replace(R.id.main, valueFragment, VALUE_TAG).commit(); if (getIntent().getAction().equals(ACTION_FULLSCREEN)) { ValueData valueData = (ValueData) getIntent().getSerializableExtra(EXTRA_VALUE); valueFragment.setValueData(valueData); setResult(0); } Boolean autostart = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("autostart", true); AutostartRegister.register(getPackageManager(), autostart); Toolbar t = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(t); ViewCompat.setTransitionName(t, "toolbar"); mAdapter = NfcAdapter.getDefaultAdapter(this); mIntentFilter = new IntentFilter("android.nfc.action.ADAPTER_STATE_CHANGED"); // Create a generic PendingIntent that will be deliver to this activity. // The NFC stack // will fill in the intent with the details of the discovered tag before // delivering to // this activity. mPendingIntent = PendingIntent.getActivity(this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); // Setup an intent filter IntentFilter tech = new IntentFilter(NfcAdapter.ACTION_TECH_DISCOVERED); mFilters = new IntentFilter[] { tech, }; mTechLists = new String[][] { new String[] { IsoDep.class.getName(), NfcA.class.getName() } }; if (getIntent().getAction().equals(ACTION_FULLSCREEN) && !hasNewData) { ValueData valueData = (ValueData) getIntent().getSerializableExtra(EXTRA_VALUE); Log.w(TAG, "restoring data for fullscreen"); valueFragment.setValueData(valueData); } }
From source file:com.codebutler.farebot.activities.AddKeyActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_add_key); getWindow().setLayout(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.FILL_PARENT); findViewById(R.id.cancel).setOnClickListener(new View.OnClickListener() { @Override/*from w w w . jav a 2 s . c om*/ public void onClick(View view) { setResult(RESULT_CANCELED); finish(); } }); findViewById(R.id.add).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { final String keyType = ((RadioButton) findViewById(R.id.is_key_a)).isChecked() ? ClassicSectorKey.TYPE_KEYA : ClassicSectorKey.TYPE_KEYB; new BetterAsyncTask<Void>(AddKeyActivity.this, true, false) { @Override protected Void doInBackground() throws Exception { ClassicCardKeys keys = ClassicCardKeys.fromDump(keyType, mKeyData); ContentValues values = new ContentValues(); values.put(KeysTableColumns.CARD_ID, mTagId); values.put(KeysTableColumns.CARD_TYPE, mCardType); values.put(KeysTableColumns.KEY_DATA, keys.toJSON().toString()); getContentResolver().insert(CardKeyProvider.CONTENT_URI, values); return null; } @Override protected void onResult(Void unused) { Intent intent = new Intent(AddKeyActivity.this, KeysActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); finish(); } }.execute(); } }); mNfcAdapter = NfcAdapter.getDefaultAdapter(this); Utils.checkNfcEnabled(this, mNfcAdapter); Intent intent = getIntent(); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); mPendingIntent = PendingIntent.getActivity(this, 0, intent, 0); if (getIntent().getAction() != null && getIntent().getAction().equals(Intent.ACTION_VIEW) && getIntent().getData() != null) { try { InputStream stream = getContentResolver().openInputStream(getIntent().getData()); mKeyData = IOUtils.toByteArray(stream); } catch (IOException e) { Utils.showErrorAndFinish(this, e); } } else { finish(); } }
From source file:com.bobomee.android.common.util.NotificationUtil.java
public static NotificationCompat.Builder setBroadCastIntent(NotificationCompat.Builder mBuilder, Context context, Intent intent) { // ?ACTIONIntent intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(pendingIntent); return mBuilder; }
From source file:com.rocketsingh.biker.GCMIntentService.java
/** * Issues a notification to inform the user that server has sent a message. *///from ww w .ja va 2 s .co m public static void generateNotification(Context context, String message) { int icon = R.drawable.ic_launcher; long when = System.currentTimeMillis(); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = new Notification(icon, message, when); String title = context.getString(R.string.app_name); Intent notificationIntent = new Intent(context, MapActivity.class); notificationIntent.putExtra("fromNotification", "notification"); // 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, PendingIntent.FLAG_UPDATE_CURRENT); notification.setLatestEventInfo(context, title, message, intent); notification.flags |= Notification.FLAG_AUTO_CANCEL; System.out.println("notification====>" + message); notification.defaults |= Notification.DEFAULT_SOUND; notification.defaults |= Notification.DEFAULT_VIBRATE; // notification.defaults |= Notification.DEFAULT_LIGHTS; notification.flags |= Notification.FLAG_SHOW_LIGHTS; notification.ledARGB = 0x00000000; notification.ledOnMS = 0; notification.ledOffMS = 0; notificationManager.notify(AndyConstants.NOTIFICATION_ID, notification); PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wakeLock = pm.newWakeLock( PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, "WakeLock"); wakeLock.acquire(); wakeLock.release(); }
From source file:com.honkidenihongo.pre.service.JilFirebaseMessagingService.java
/** * Create and show a simple notification containing the received FCM message. * * @param message FCM message body received. */// ww w. j a v a2 s . com private void sendNotification(String title, String message, long team_id, String team_name) { Intent intent = new Intent(this, MainActivity.class); intent.putExtra(Definition.General.TEAM_ID, team_id); intent.putExtra(Definition.General.TEAM_NAME, team_name); intent.putExtra(Definition.General.PUSH_NOTIFICATION, true); intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, (int) System.currentTimeMillis(), intent, PendingIntent.FLAG_UPDATE_CURRENT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.mipmap.ic_launcher).setContentTitle(title).setContentText(message) .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify((int) System.currentTimeMillis(), notificationBuilder.build()); }
From source file:jp.co.ipublishing.esnavi.impl.gcm.GcmIntentService.java
/** * Notification??/*from ww w . j a v a 2s . c om*/ * * @param alert */ private void sendNotification(@NonNull Alert alert) { final NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); final Intent resultIntent = new Intent(this, MapActivity.class) .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); final PendingIntent contentIntent = PendingIntent.getActivity(this, 1, resultIntent, PendingIntent.FLAG_UPDATE_CURRENT); final Notification.Builder builder = new Notification.Builder(this).setWhen(System.currentTimeMillis()) .setContentIntent(contentIntent) .setDefaults( Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE | Notification.DEFAULT_LIGHTS) .setAutoCancel(true).setTicker(alert.getHeadlineBody()).setContentText(alert.getHeadlineBody()); onPreSendNotification(builder, alert); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { notificationManager.notify(NOTIFICATION_ID, builder.build()); } else { notificationManager.notify(NOTIFICATION_ID, builder.getNotification()); } }
From source file:com.adkdevelopment.rssreader.data.services.FetchJobService.java
/** * Raises a notification each day on news update. */// ww w. j a v a2 s. c o m private void sendNotification() { PrefsManager prefsManager = new PrefsManager(getBaseContext()); Context context = getApplicationContext(); final String NOTIFICATION_GROUP = "notif_group"; final int NOTIFICATION_ID_1 = 101; if (prefsManager.receiveNotifications()) { //checking the last update and notify if it's the first of the day if (System.currentTimeMillis() - prefsManager.getLastNotification() >= DateUtils.DAY_IN_MILLIS) { Intent intent = new Intent(context, MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(context, NOTIFICATION_ID_1, intent, PendingIntent.FLAG_UPDATE_CURRENT); NotificationCompat.Builder builder = new NotificationCompat.Builder(context); builder.setDefaults(Notification.DEFAULT_ALL).setAutoCancel(true) .setContentTitle(context.getString(R.string.app_name)) .setContentText(context.getString(R.string.articles_notification)) .setContentIntent(pendingIntent).setSmallIcon(R.drawable.logo_title) .setTicker(context.getString(R.string.app_name)) .setStyle(new NotificationCompat.BigTextStyle() .bigText(context.getString(R.string.articles_notification))) .setGroup(NOTIFICATION_GROUP).setGroupSummary(true); NotificationManagerCompat managerCompat = NotificationManagerCompat.from(context); managerCompat.notify(NOTIFICATION_ID_1, builder.build()); prefsManager.setLastNotification(); } } }
From source file:com.google.android.gcm.demo.app.GCMIntentService.java
/** * Issues a notification to inform the user that server has sent a message. *//*from w w w. ja va2 s .co m*/ private static void generateNotification(Context context, String message, String data) { int icon = R.drawable.ic_stat_gcm; long when = System.currentTimeMillis(); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.cancel(0); Notification notification = new Notification(icon, message, when); String title = context.getString(R.string.app_name); Intent notificationIntent = new Intent(context, DemoActivity.class); notificationIntent.putExtra(CommonUtilities.EXTRA_TEAM_IN_JSON, data); // 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, PendingIntent.FLAG_UPDATE_CURRENT); notification.setLatestEventInfo(context, title, message, intent); notification.flags = Notification.FLAG_AUTO_CANCEL; notificationManager.notify(0, notification); }
From source file:com.appdynamics.demo.gasp.gcm.GCMIntentService.java
/** * Send a notification message that a new update has been received * * @param msg Notification message/*from ww w .j av a 2 s.c o m*/ */ private void sendNotification(String msg) { NotificationManager mNotificationManager = (NotificationManager) this .getSystemService(Context.NOTIFICATION_SERVICE); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, LocationsActivity.class) .setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_stat_gcm).setContentTitle("Gasp! Update") .setStyle(new NotificationCompat.BigTextStyle().bigText(msg)).setContentText(msg); mBuilder.setContentIntent(contentIntent); mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); }