List of usage examples for android.content Intent addFlags
public @NonNull Intent addFlags(@Flags int flags)
From source file:com.versul.newbornswatcher.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received.//from w ww . j av a2 s .co m */ private void sendNotification(String message) { Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.eye); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(android.R.drawable.ic_dialog_alert) .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.notification_large)) .setContentTitle("Newborns Watcher").setContentText(message).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.commontime.plugin.notification.notification.AbstractActionClickActivity.java
/** * Launch main intent from package.// w w w . j a v a 2s.c o m */ public void launchApp() { Context context = getApplicationContext(); String pkgName = context.getPackageName(); Intent intent = context.getPackageManager().getLaunchIntentForPackage(pkgName); intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP); context.startActivity(intent); }
From source file:com.mjhram.ttaxi.gcm_client.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received./* w w w. j ava 2s .c o m*/ */ private void sendNotification(String message) { Intent intent = new Intent(this, GpsMainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.circle_green).setContentTitle(getString(R.string.gcmClientGcmMsg)) .setContentText(message).setAutoCancel(true).setSound(defaultSoundUri) .setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); }
From source file:kaist.cs492c_2015.washerbrowser.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received.//from ww w . ja va 2 s. c o m */ private void sendNotification(String message) { Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* 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_ic_notification).setContentTitle("Find available washer") .setContentText(message).setAutoCancel(true).setSound(defaultSoundUri) .setVibrate(new long[] { 1000, 1000, 1000, 1000, 1000 }).setSmallIcon(R.drawable.washer_green) .setContentIntent(pendingIntent); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(0 /* ID of notification */, notificationBuilder.build()); launchPopupActivity(this, message); }
From source file:org.roman.findme.MyGcmListenerService.java
void displayMessage(String message) { if (MessageActivity.active) { MessageActivity.addSenderMessage(message); } else {//from ww w. ja va 2 s.c o m Intent intent = new Intent(this, MessageActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra("message", message); startActivity(intent); } }
From source file:co.uk.gauntface.mobile.devicelab.receiver.PushNotificationReceiver.java
private void launchBrowserTask(Context context, String url, String packageName) { Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); browserIntent.setPackage(packageName); browserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); List<ResolveInfo> activitiesList = context.getPackageManager().queryIntentActivities(browserIntent, -1); if (activitiesList.size() > 0) { context.startActivity(browserIntent); } else {//from w ww . j av a 2 s .com Intent playStoreIntent = new Intent(Intent.ACTION_VIEW); playStoreIntent.setData(Uri.parse("market://details?id=" + packageName)); playStoreIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); context.startActivity(playStoreIntent); } }
From source file:com.josecarlos.couplecounters.LoginActivity.java
public void navigatetoRegisterActivity(View view) { Intent loginIntent = new Intent(getApplicationContext(), RegisterActivity.class); loginIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(loginIntent);//from ww w . j a va 2s .c om }
From source file:love.juhe.androidmonkey.MonkeyActivityEvent.java
/** * @return Intent for the new activity/*from www . j a va 2 s . c om*/ */ private Intent getEvent() { Intent intent = new Intent(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); intent.setComponent(mApp); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); return intent; }
From source file:com.rossier.shclechelles.service.MyGcmListenerService.java
/** * Create and show a simple notification containing the received GCM message. * * @param message GCM message received.//from w w w. java 2s .c o m */ private void sendNotification(String from, String message) { Gson gson = new GsonBuilder().create(); String messageUTF8 = ""; try { messageUTF8 = new String(message.getBytes(), "UTF-8"); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } Log.i("MyGCMListenerService", message); Log.i("MyGCMListenerService", messageUTF8); if (messageUTF8 == "") return; MatchNotification match = gson.fromJson(messageUTF8, MatchNotification.class); Intent intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT); int icon = R.drawable.ic_launcher_shc; long when = System.currentTimeMillis(); // Notification notification = new Notification(icon, "Nouveaux rsultats", when); Notification notification = new Notification.Builder(this.getBaseContext()) .setContentText("Nouveaux rsultats").setSmallIcon(icon).setWhen(when).build(); NotificationManager mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.match_notif_layout); contentView.setTextViewText(R.id.notif_team_home, match.getTeam_home()); contentView.setTextViewText(R.id.notif_team_away, match.getTeam_away()); contentView.setTextViewText(R.id.notif_result_home, match.getResult_home() + ""); contentView.setTextViewText(R.id.notif_result_away, match.getResult_away() + ""); contentView.setTextViewText(R.id.notif_ligue, match.getLigue()); contentView.setImageViewResource(R.id.notif_team_loc_logo, Utils.getLogo(match.getTeam_home())); contentView.setImageViewResource(R.id.notif_team_away_logo, Utils.getLogo(match.getTeam_away())); notification.contentView = contentView; Intent notificationIntent = new Intent(this, MainActivity.class); PendingIntent contentIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0); notification.contentIntent = contentIntent; //notification.flags |= Notification.FLAG_ONGOING_EVENT; //Do not clear the notification notification.defaults |= Notification.DEFAULT_LIGHTS; // LED notification.defaults |= Notification.DEFAULT_VIBRATE; //Vibration notification.defaults |= Notification.DEFAULT_SOUND; // Sound //get topics name String[] topic = from.split("/"); mNotificationManager.notify(topic[2].hashCode(), notification); }
From source file:com.qrcode.app.zxing.decoding.CaptureActivityHandler.java
@Override public void handleMessage(Message message) { switch (message.what) { case R.id.auto_focus: //Log.d(TAG, "Got auto-focus message"); // When one auto focus pass finishes, start another. This is the closest thing to // continuous AF. It does seem to hunt a bit, but I'm not sure what else to do. if (state == State.PREVIEW) { CameraManager.get().requestAutoFocus(this, R.id.auto_focus); }/* www .java 2 s . c om*/ break; case R.id.restart_preview: Log.d(TAG, "Got restart preview message"); restartPreviewAndDecode(); break; case R.id.decode_succeeded: Log.d(TAG, "Got decode succeeded message"); state = State.SUCCESS; Bundle bundle = message.getData(); /***********************************************************************/ Bitmap barcode = bundle == null ? null : (Bitmap) bundle.getParcelable(DecodeThread.BARCODE_BITMAP);//?????????? try { activity.handleDecode((Result) message.obj, barcode);//??????? /***********************************************************************/ } catch (JSONException e) { e.printStackTrace(); } break; case R.id.decode_failed: // We're decoding as fast as possible, so when one decode fails, start another. state = State.PREVIEW; CameraManager.get().requestPreviewFrame(decodeThread.getHandler(), R.id.decode); break; case R.id.return_scan_result: Log.d(TAG, "Got return scan result message"); activity.setResult(Activity.RESULT_OK, (Intent) message.obj); activity.finish(); break; case R.id.launch_product_query: Log.d(TAG, "Got product query message"); String url = (String) message.obj; Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET); activity.startActivity(intent); break; } }