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:edu.polyu.screamalert.SoundProcessing.java
@SuppressWarnings("unchecked") public static void initialize(Context context) { thisContext = context;/*from w w w . java 2s. c om*/ x = new float[samplePerFrm]; subx = new float[frameShift]; // Samples in a sub-frame mfcc = new MFCC(samplePerFrm, Config.RECORDER_SAMPLERATE, numMfcc); ccBuf = new CircularFifoBuffer(K); // Buffer storing K mfcc vectors dccBuf = new CircularFifoBuffer(K); // Buffer storing K delta-mfcc vectors pDet = new YinPitchDetector(Config.RECORDER_SAMPLERATE, samplePerFrm); piBuf = new CircularFifoBuffer(K); pkBuf = new CircularFifoBuffer(K); mu_z = new double[] { VoiceQuality.JITTER_MEAN, VoiceQuality.SHIMMER_MEAN }; // Jitter and shimmer mean sigma_z = new double[] { VoiceQuality.JITTER_STD, VoiceQuality.SHIMMER_STD }; // Jitter and shimmer stddev aList = new ArrayList<double[]>(); enBuf = new CircularFifoBuffer(enBufSize); // Circular buffer storing energy profile of the latest K frames frmBuf = new CircularFifoBuffer(K); // Buffer storing K latest frames of audio signals */ for (int k = 0; k < K; k++) { ccBuf.add(new double[numMfcc + 1]); // Initialize MFCC FIFO buffers dccBuf.add(new double[numMfcc + 1]); // Initialize delta MFCC FIFO buffers piBuf.add(-1.0D); // Initialize pitch FIFO buffer for computing jitter and shimmer pkBuf.add(0.0D); // Initialize peak amplitude FIFO buffer for computing shimmer frmBuf.add(new double[samplePerFrm]); // Initialize frame buffer } for (int k = 0; k < enBufSize; k++) { enBuf.add(new double[1]); // Initialize energy buffer } mainIntent = new Intent(thisContext, SoundProcessingSetting.class); mainIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); pIntent = PendingIntent.getActivity(thisContext, 0, mainIntent, 0); // Go back to MainActivity when user press the notification noti = new NotificationCompat.Builder(thisContext) .setContentTitle( thisContext.getString(R.string.app_name) + " " + thisContext.getString(R.string.running)) .setContentText(thisContext.getString(R.string.configure)).setSmallIcon(R.drawable.ic_launcher) .setContentIntent(pIntent).build(); noti.flags = Notification.FLAG_FOREGROUND_SERVICE; if (SoundProcessingActivity.thisActivity == null) calibrateDialog = new ProgressDialog(Exchanger.thisContext); else calibrateDialog = new ProgressDialog(SoundProcessingActivity.thisActivity); }
From source file:com.hoangsong.zumechat.gcm.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * *///from ww w . ja v a 2s . com private void sendNotification(CustomNotification customNotification) { String title = getString(R.string.app_name); long when = System.currentTimeMillis(); NotificationCompat.Builder mBuilder = null; if (customNotification.getSound().equals("0") && customNotification.getVibrate().equals("0")) { mBuilder = new NotificationCompat.Builder(getApplicationContext()).setSmallIcon(R.mipmap.ic_launcher) //.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_launcher)) .setContentTitle(title).setContentText(customNotification.getMessage())// + " " + notificationsList.get(notificationsList.size()-1).getTime()) //.setNumber(count) .setWhen(when).setAutoCancel(true) //.setStyle(new NotificationCompat.BigTextStyle().bigText(notificationsList.get(notificationsList.size()-1).getMSG() + " " + notificationsList.get(notificationsList.size()-1).getTime())) //.setStyle(bigTextStyle) //.setTicker(message) ; } else if (customNotification.getSound().equals("1")) { mBuilder = new NotificationCompat.Builder(getApplicationContext()).setSmallIcon(R.mipmap.ic_launcher) //.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_launcher)) .setContentTitle(title).setContentText(customNotification.getMessage())// + " " + notificationsList.get(notificationsList.size()-1).getTime()) //.setNumber(count) .setWhen(when).setDefaults(Notification.DEFAULT_SOUND).setAutoCancel(true) //.setStyle(new NotificationCompat.BigTextStyle().bigText(notificationsList.get(notificationsList.size()-1).getMSG() + " " + notificationsList.get(notificationsList.size()-1).getTime())) //.setStyle(bigTextStyle) //.setTicker(message) ; } else if (customNotification.getVibrate().equals("1")) { mBuilder = new NotificationCompat.Builder(getApplicationContext()).setSmallIcon(R.mipmap.ic_launcher) //.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_launcher)) .setContentTitle(title).setContentText(customNotification.getMessage())// + " " + notificationsList.get(notificationsList.size()-1).getTime()) //.setNumber(count) .setWhen(when).setDefaults(Notification.DEFAULT_VIBRATE).setAutoCancel(true) //.setStyle(new NotificationCompat.BigTextStyle().bigText(notificationsList.get(notificationsList.size()-1).getMSG() + " " + notificationsList.get(notificationsList.size()-1).getTime())) //.setStyle(bigTextStyle) //.setTicker(message) ; } else { Log.e(Constants.TAG, MyGcmListenerService.class.getName() + " Exception: test all"); mBuilder = new NotificationCompat.Builder(getApplicationContext()).setSmallIcon(R.mipmap.ic_launcher) //.setLargeIcon(BitmapFactory.decodeResource(context.getResources(), R.drawable.ic_launcher)) .setContentTitle(title).setContentText(customNotification.getMessage())// + " " + notificationsList.get(notificationsList.size()-1).getTime()) //.setNumber(count) .setWhen(when).setDefaults(Notification.DEFAULT_ALL).setAutoCancel(true) //.setStyle(new NotificationCompat.BigTextStyle().bigText(notificationsList.get(notificationsList.size()-1).getMSG() + " " + notificationsList.get(notificationsList.size()-1).getTime())) //.setStyle(bigTextStyle) //.setTicker(message) ; } // Creates an explicit intent for an Activity in your app Intent notificationIntent = new Intent(getApplicationContext(), MainActivityPhone.class); if (customNotification != null) { Bundle bundle = new Bundle(); bundle.putSerializable("customNotification", customNotification); notificationIntent.putExtras(bundle); } notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); // The stack builder object will contain an artificial back stack for the // started Activity. // This ensures that navigating backward from the Activity leads out of // your application to the Home screen. TaskStackBuilder stackBuilder = TaskStackBuilder.create(getApplicationContext()); // Adds the back stack for the Intent (but not the Intent itself) stackBuilder.addParentStack(MainActivityPhone.class); // Adds the Intent that starts the Activity to the top of the stack stackBuilder.addNextIntent(notificationIntent); PendingIntent resultPendingIntent = stackBuilder.getPendingIntent(customNotification.getId(), PendingIntent.FLAG_UPDATE_CURRENT); mBuilder.setContentIntent(resultPendingIntent); NotificationManager mNotificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); // mId allows you to update the notification later on. mNotificationManager.notify(customNotification.getId(), mBuilder.build()); //Constants.NOTIFICATION_TYPE_ANNOUNCEMENT, mBuilder.build()); }
From source file:com.preguardia.app.notification.MyGcmListenerService.java
private void showPatientNotification(String title, String message, String consultationId) { // Prepare intent which is triggered if the notification is selected Intent intent = new Intent(this, ConsultationDetailsActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.putExtra(Constants.EXTRA_CONSULTATION_ID, consultationId); PendingIntent pendingIntent = PendingIntent.getActivity(this, Constants.PATIENT_REQUEST_CODE, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_stat_logo).setContentTitle(title).setContentText(message) .setAutoCancel(true).setSound(defaultSoundUri).setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(3, notificationBuilder.build()); }
From source file:com.airbop.client.GCMIntentService.java
private static void generateNotification(Context context, String title, String message, String url, String large_icon) {/*from w w w. ja v a 2 s .co m*/ 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.BigTextStyle().bigText(message)).build(); notification.flags |= Notification.FLAG_AUTO_CANCEL; notificationManager.notify(0, notification); }
From source file:cn.studyjams.s2.sj0132.bowenyan.mygirlfriend.nononsenseapps.notepad.ui.list.ActivityList.java
@Override public void openTask(final Uri taskUri, final long listId, final View origin) { // Todo change activity final Intent intent = new Intent().setAction(Intent.ACTION_EDIT).setClass(this, ActivityEditor.class) .setData(taskUri).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP) .putExtra(TaskDetailFragment.ARG_ITEM_LIST_ID, listId); // User clicked a task in the list // tablet/* w ww . j a v a 2 s .co m*/ // todo tablet /*if (fragment2 != null) { // Set the intent here also so rotations open the same item setIntent(intent); getSupportFragmentManager().beginTransaction().setCustomAnimations(R.anim .slide_in_top, R.anim.slide_out_bottom).replace(R.id.fragment2, TaskDetailFragment_.getInstance(taskUri)).commitAllowingStateLoss(); taskHint.setVisibility(View.GONE); } // phone else {*/ startActivity(intent); // } //} }
From source file:com.wmstein.transektcount.EditSectionActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); if (id == R.id.home) { Intent intent = NavUtils.getParentActivityIntent(this); intent.putExtra("section_id", section_id); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); NavUtils.navigateUpTo(this, intent); } else if (id == R.id.menuSaveExit) { if (saveData()) { savedCounts.clear();// ww w.j av a 2s. c o m super.finish(); } } else if (id == R.id.newCount) { newCount(findViewById(R.id.editingCountsLayout)); } return super.onOptionsItemSelected(item); }
From source file:com.weddingsingers.wsapp.fcm.MyFirebaseMessagingService.java
/** * Create and show a simple notification containing the received FCM message. * * @param messageBody FCM message body received. *///from w w w . j a va 2 s. co m private void sendNotification(String messageBody, String action) { Intent intent = new Intent(this, SplashActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); switch (action) { case ACTION_RESERVATION_LIST: { intent.putExtra(SplashActivity.EXTRA_FRAGNAME, MainActivity.FRAG_RESERVATION_MGM); break; } case ACTION_RESERVED_CUSTOMER: { intent.putExtra(SplashActivity.EXTRA_FRAGNAME, MainActivity.FRAG_RESERVED_CUSTOMER); break; } case ACTION_SCHEDULE_MGM: { intent.putExtra(SplashActivity.EXTRA_FRAGNAME, MainActivity.FRAG_SCHEDULE_MGM); break; } case ACTION_VIDEO: { intent.putExtra(SplashActivity.EXTRA_FRAGNAME, MainActivity.FRAG_VIDEO); break; } case ACTION_CHATTING: { intent.putExtra(SplashActivity.EXTRA_FRAGNAME, ChattingActivity.class); break; } } 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(messageBody).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.syncedsynapse.kore2.ui.hosts.HostListFragment.java
/** * Starts add host activity//www .j a v a 2 s . co m */ public void startAddHostWizard() { Intent launchIntent = new Intent(getActivity(), AddHostActivity.class) .addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); startActivity(launchIntent); getActivity().overridePendingTransition(R.anim.activity_in, R.anim.activity_out); }
From source file:com.bayapps.android.robophish.MediaNotificationManager.java
private PendingIntent createContentIntent(MediaDescriptionCompat description) { Intent openUI = new Intent(mService, MusicPlayerActivity.class); openUI.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); openUI.putExtra(MusicPlayerActivity.EXTRA_START_FULLSCREEN, true); if (description != null) { openUI.putExtra(MusicPlayerActivity.EXTRA_CURRENT_MEDIA_DESCRIPTION, description); }/*from w w w. ja va 2 s. co m*/ return PendingIntent.getActivity(mService, REQUEST_CODE, openUI, PendingIntent.FLAG_CANCEL_CURRENT); }
From source file:com.moonpi.tapunlock.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Get lobster_two asset and create typeface // Set action bar title to lobster_two typeface lobsterTwo = Typeface.createFromAsset(getAssets(), "lobster_two.otf"); int actionBarTitle = Resources.getSystem().getIdentifier("action_bar_title", "id", "android"); actionBarTitleView = (TextView) getWindow().findViewById(actionBarTitle); if (actionBarTitleView != null) { actionBarTitleView.setTypeface(lobsterTwo); actionBarTitleView.setTextSize(TypedValue.COMPLEX_UNIT_SP, 28f); actionBarTitleView.setTextColor(getResources().getColor(R.color.blue)); }/*from w w w . j a va 2 s .co m*/ setContentView(R.layout.activity_main); // Hide keyboard on app launch this.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); // Get NFC service and adapter NfcManager nfcManager = (NfcManager) this.getSystemService(Context.NFC_SERVICE); nfcAdapter = nfcManager.getDefaultAdapter(); // Create PendingIntent for enableForegroundDispatch for NFC tag discovery pIntent = PendingIntent.getActivity(this, 0, new Intent(this, getClass()).addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP), 0); readFromJSON(); writeToJSON(); readFromJSON(); // If Android 4.2 or bigger if (Build.VERSION.SDK_INT > 16) { // Check if TapUnlock folder exists, if not, create directory File folder = new File(Environment.getExternalStorageDirectory() + "/TapUnlock"); boolean folderSuccess = true; if (!folder.exists()) { folderSuccess = folder.mkdir(); } try { // If blur var bigger than 0 if (settings.getInt("blur") > 0) { // If folder exists or successfully created if (folderSuccess) { // If blurred wallpaper file doesn't exist if (!ImageUtils.doesBlurredWallpaperExist()) { // Get default wallpaper WallpaperManager wallpaperManager = WallpaperManager.getInstance(this); final Drawable wallpaperDrawable = wallpaperManager.peekFastDrawable(); if (wallpaperDrawable != null) { // Default wallpaper to bitmap - fastBlur the bitmap - store bitmap new Thread(new Runnable() { @Override public void run() { Bitmap bitmapToBlur = ImageUtils.drawableToBitmap(wallpaperDrawable); Bitmap blurredWallpaper = null; if (bitmapToBlur != null) blurredWallpaper = ImageUtils.fastBlur(MainActivity.this, bitmapToBlur, blur); if (blurredWallpaper != null) { ImageUtils.storeImage(blurredWallpaper); } } }).start(); } } } } } catch (JSONException e) { e.printStackTrace(); } } // Initialize layout items pinEdit = (EditText) findViewById(R.id.pinEdit); pinEdit.setImeOptions(EditorInfo.IME_ACTION_DONE); Button setPin = (Button) findViewById(R.id.setPin); ImageButton newTag = (ImageButton) findViewById(R.id.newTag); enabled_disabled = (TextView) findViewById(R.id.enabled_disabled); Switch toggle = (Switch) findViewById(R.id.toggle); seekBar = (SeekBar) findViewById(R.id.seekBar); progressBar = (ProgressBar) findViewById(R.id.progressBar); Button refreshWallpaper = (Button) findViewById(R.id.refreshWallpaper); listView = (ListView) findViewById(R.id.listView); backgroundBlurValue = (TextView) findViewById(R.id.backgroundBlurValue); noTags = (TextView) findViewById(R.id.noTags); // Initialize TagAdapter adapter = new TagAdapter(this, tags); registerForContextMenu(listView); // Set listView adapter to TapAdapter object listView.setAdapter(adapter); // Set click, check and seekBar listeners setPin.setOnClickListener(this); newTag.setOnClickListener(this); refreshWallpaper.setOnClickListener(this); toggle.setOnCheckedChangeListener(this); seekBar.setOnSeekBarChangeListener(this); // Set seekBar progress to blur var try { seekBar.setProgress(settings.getInt("blur")); } catch (JSONException e) { e.printStackTrace(); } // Refresh the listView height updateListViewHeight(listView); // If no tags, show 'Press + to add Tags' textView if (tags.length() == 0) noTags.setVisibility(View.VISIBLE); else noTags.setVisibility(View.INVISIBLE); // Scroll up scrollView = (ScrollView) findViewById(R.id.scrollView); scrollView.post(new Runnable() { public void run() { scrollView.scrollTo(0, scrollView.getTop()); scrollView.fullScroll(View.FOCUS_UP); } }); // If lockscreen enabled, initialize switch, text and start service try { if (settings.getBoolean("lockscreen")) { onStart = true; enabled_disabled.setText(R.string.lockscreen_enabled); enabled_disabled.setTextColor(getResources().getColor(R.color.green)); toggle.setChecked(true); } } catch (JSONException e1) { e1.printStackTrace(); } }