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.marianhello.cordova.bgloc.LocationUpdateService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { Log.i(TAG, "Received start id " + startId + ": " + intent); if (intent != null) { try { params = new JSONObject(intent.getStringExtra("params")); headers = new JSONObject(intent.getStringExtra("headers")); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace();//from w w w . j a v a2 s . com } url = intent.getStringExtra("url"); stationaryRadius = Float.parseFloat(intent.getStringExtra("stationaryRadius")); distanceFilter = Integer.parseInt(intent.getStringExtra("distanceFilter")); scaledDistanceFilter = distanceFilter; desiredAccuracy = Integer.parseInt(intent.getStringExtra("desiredAccuracy")); locationTimeout = Integer.parseInt(intent.getStringExtra("locationTimeout")); isDebugging = Boolean.parseBoolean(intent.getStringExtra("isDebugging")); notificationTitle = intent.getStringExtra("notificationTitle"); notificationText = intent.getStringExtra("notificationText"); // Build a Notification required for running service in foreground. Intent main = new Intent(this, BackgroundGpsPlugin.class); main.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, main, PendingIntent.FLAG_UPDATE_CURRENT); Notification.Builder builder = new Notification.Builder(this); builder.setContentTitle(notificationTitle); builder.setContentText(notificationText); builder.setSmallIcon(android.R.drawable.ic_menu_mylocation); builder.setContentIntent(pendingIntent); Notification notification; if (android.os.Build.VERSION.SDK_INT >= 16) { notification = buildForegroundNotification(builder); } else { notification = buildForegroundNotificationCompat(builder); } notification.flags |= Notification.FLAG_ONGOING_EVENT | Notification.FLAG_FOREGROUND_SERVICE | Notification.FLAG_NO_CLEAR; startForeground(startId, notification); } Log.i(TAG, "- url: " + url); Log.i(TAG, "- params: " + params.toString()); Log.i(TAG, "- headers: " + headers.toString()); Log.i(TAG, "- stationaryRadius: " + stationaryRadius); Log.i(TAG, "- distanceFilter: " + distanceFilter); Log.i(TAG, "- desiredAccuracy: " + desiredAccuracy); Log.i(TAG, "- locationTimeout: " + locationTimeout); Log.i(TAG, "- isDebugging: " + isDebugging); Log.i(TAG, "- notificationTitle: " + notificationTitle); Log.i(TAG, "- notificationText: " + notificationText); this.setPace(false); //We want this service to continue running until it is explicitly stopped return START_REDELIVER_INTENT; }
From source file:com.linute.linute.API.MyGcmListenerService.java
private Intent buildIntent(Bundle data, String action) { Intent intent;/*from w w w . jav a2 s .co m*/ //Log.i(TAG, "action : " + action); Log.d(TAG, "sendNotification: " + data.toString()); boolean isLoggedIn = getSharedPreferences(LinuteConstants.SHARED_PREF_NAME, MODE_PRIVATE) .getBoolean("isLoggedIn", false); if (!isLoggedIn) { intent = new Intent(this, PreLoginActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); return intent; } if (action == null) { intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); return intent; } int type = gettNotificationType(data.getString("action")); if (type == LinuteConstants.MISC) { intent = new Intent(this, LaunchActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); return intent; } if (type == LinuteConstants.GLOBAL) { intent = new Intent(this, LaunchActivity.class); intent.putExtra(LaunchActivity.EXTRA_REPORT_NOTIF_OPENED, true); intent.putExtra(LaunchActivity.EXTRA_NOTIF_ID, data.getString("nid")); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); return intent; } intent = new Intent(this, MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); intent.putExtra("NOTIFICATION", type); if (type == LinuteConstants.MESSAGE) { intent.putExtra("NOTIFICATION", type); try { JSONObject image = new JSONObject( data.getString("roomProfileImage", "{original:'', thumbnail:''}")); JSONArray users = new JSONArray(data.getString("roomUsers", "[]")); String myId = Utils.getMyId(getApplicationContext()); ArrayList<User> usersList = new ArrayList<>(users.length()); for (int u = 0; u < users.length(); u++) { JSONObject userJson = users.getJSONObject(u); if (!myId.equals(userJson.getString("id"))) { usersList.add(new User(userJson.getString("id"), userJson.getString("firstName"), "", "")); } } Log.d("AAA", data.getString("room", "")); ChatRoom chatRoom = new ChatRoom(data.getString("room", ""), Integer.parseInt(data.getString("roomType", "" + ChatRoom.ROOM_TYPE_GROUP)), data.getString("roomNameOfGroup", null), image.getString("thumbnail"), usersList, "", true, 0, false, 0); intent.putExtra("chatRoom", chatRoom); /*intent.putExtra("ownerID", data.getString("ownerID")); intent.putExtra("ownerFirstName", data.getString("ownerFullName")); intent.putExtra("ownerLastName", data.getString("ownerLastName")); intent.putExtra("room", data.getString("room"));*/ } catch (JSONException e) { e.printStackTrace(); } } else if (type == LinuteConstants.FEED_DETAIL) { intent.putExtra("event", data.getString("event")); } else { intent.putExtra("user", data.getString("user")); } return intent; }
From source file:com.nps.micro.UsbService.java
/** * Show a notification service is finished testing microcontrollers. *///from www . ja va 2 s. com public void showTestDoneNotification() { Intent intent = new Intent(this, MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); Notification notification = new NotificationCompat.Builder(getApplicationContext()) .setContentIntent(PendingIntent.getActivity(this, 0, intent, 0)) .setSmallIcon(R.drawable.ic_launcher).setContentText(getText(R.string.local_service_test_done)) .setContentTitle(getText(R.string.local_service_notification)).build(); notificationManager.notify(NOTIFICATION, notification); status = new Status(getString(R.string.ready), false); sendStatusMessage(); }
From source file:com.vendsy.bartsy.venue.GCMIntentService.java
/** * To generate a notification to inform the user that server has sent a message. * /* w ww. j a v a2 s . co m*/ * @param count * @param count */ private static void generateNotification(Context context, String message, String count) { 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, 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, title, message, intent); notification.flags |= Notification.FLAG_AUTO_CANCEL; try { int countValue = Integer.parseInt(count); notification.number = countValue; } catch (NumberFormatException e) { e.printStackTrace(); } // // Play default notification sound notification.defaults = Notification.DEFAULT_SOUND; notificationManager.notify(0, notification); }
From source file:com.elekso.potfix.MainActivity.java
private void createNotification() { // BEGIN_INCLUDE(notificationCompat) NotificationCompat.Builder builder = new NotificationCompat.Builder(this); // END_INCLUDE(notificationCompat) // BEGIN_INCLUDE(intent) //Create Intent to launch this Activity again if the notification is clicked. Intent i = new Intent(this, MainActivity.class); i.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent intent = PendingIntent.getActivity(this, 0, i, PendingIntent.FLAG_UPDATE_CURRENT); builder.setContentIntent(intent);/*from ww w.java2 s . c o m*/ // END_INCLUDE(intent) // BEGIN_INCLUDE(ticker) // Sets the ticker text builder.setTicker(getResources().getString(R.string.custom_notification)); // Sets the small icon for the ticker builder.setSmallIcon(R.drawable.icon4_1); // END_INCLUDE(ticker) // BEGIN_INCLUDE(buildNotification) // Cancel the notification when clicked builder.setAutoCancel(true); // Build the notification Notification notification = builder.build(); // END_INCLUDE(buildNotification) // BEGIN_INCLUDE(customLayout) // Inflate the notification layout as RemoteViews RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.notification); // Set text on a TextView in the RemoteViews programmatically. final String time = DateFormat.getTimeInstance().format(new Date()).toString(); final String text = getResources().getString(R.string.collapsed, time); contentView.setTextViewText(R.id.textView, text); /* Workaround: Need to set the content view here directly on the notification. * NotificationCompatBuilder contains a bug that prevents this from working on platform * versions HoneyComb. * See https://code.google.com/p/android/issues/detail?id=30495 */ notification.contentView = contentView; // Add a big content view to the notification if supported. // Support for expanded notifications was added in API level 16. // (The normal contentView is shown when the notification is collapsed, when expanded the // big content view set here is displayed.) if (Build.VERSION.SDK_INT >= 16) { // Inflate and set the layout for the expanded notification view RemoteViews expandedView = new RemoteViews(getPackageName(), R.layout.notification_expanded); notification.bigContentView = expandedView; } // END_INCLUDE(customLayout) // START_INCLUDE(notify) // Use the NotificationManager to show the notification NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); nm.notify(0, notification); // END_INCLUDE(notify) }
From source file:de.qspool.clementineremote.ui.MainActivity.java
@Override public void onDestroy() { super.onDestroy(); Log.d(TAG, "onDestroy"); // If we disconnected, open connectdialog if (App.mClementineConnection == null || App.mClementine == null || !App.mClementineConnection.isConnected()) { Log.d(TAG, "onDestroy - disconnect"); if (mOpenConnectDialog) { Intent connectDialog = new Intent(this, ConnectDialog.class); connectDialog.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); startActivity(connectDialog); }/*from w w w. j a v a 2 s .com*/ } }
From source file:gpsalarm.app.service.PostMonitor.java
private void showProximityNotification(String string) { final NotificationManager mgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); Notification note = new Notification(R.drawable.status, "Friend@ notification!", System.currentTimeMillis()); Intent i = new Intent(this, AlertList.class); // i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP| // Intent.FLAG_ACTIVITY_SINGLE_TOP); i.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); PendingIntent pi = PendingIntent.getActivity(this, 0, i, 0); note.setLatestEventInfo(this, "Friend@ notification", string, pi); mgr.notify(NOTIFICATION_ID, note);//w w w.j a v a 2 s .co m }
From source file:com.xperia64.rompatcher.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); staticThis = MainActivity.this; setContentView(R.layout.main);/*from www . ja v a2s .com*/ // Load native libraries try { System.loadLibrary("apsn64patcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab apspatcher!"); } try { System.loadLibrary("ipspatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab ipspatcher!"); } try { System.loadLibrary("ipspatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab ipspatcher!"); } try { System.loadLibrary("upspatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab upspatcher!"); } try { System.loadLibrary("xdelta3patcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab xdelta3patcher!"); } try { System.loadLibrary("bpspatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab bpspatcher!"); } try { System.loadLibrary("bzip2"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab bzip2!"); } try { System.loadLibrary("bsdiffpatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab bsdiffpatcher!"); } try { System.loadLibrary("ppfpatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab ppfpatcher!"); } try { System.loadLibrary("ips32patcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab ips32patcher!"); } try { System.loadLibrary("glib-2.0"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab glib-2.0!"); } try { System.loadLibrary("gmodule-2.0"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab gmodule-2.0!"); } try { System.loadLibrary("edsio"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab edsio!"); } try { System.loadLibrary("xdelta1patcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab ips32patcher!"); } try { System.loadLibrary("ips32patcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab ips32patcher!"); } try { System.loadLibrary("ecmpatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab ecmpatcher!"); } try { System.loadLibrary("dpspatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab dpspatcher!"); } try { System.loadLibrary("dldipatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab dldipatcher!"); } try { System.loadLibrary("xpcpatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab xpcpatcher!"); } try { System.loadLibrary("asarpatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab asarpatcher!"); } try { System.loadLibrary("asmpatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab asmpatcher!"); } c = (CheckBox) findViewById(R.id.backupCheckbox); d = (CheckBox) findViewById(R.id.altNameCheckbox); r = (CheckBox) findViewById(R.id.ignoreCRC); e = (CheckBox) findViewById(R.id.fileExtCheckbox); ed = (EditText) findViewById(R.id.txtOutFile); final Button romButton = (Button) findViewById(R.id.romButton); romButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Globals.mode = true; Intent intent = new Intent(staticThis, FileBrowserActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); startActivityForResult(intent, 1); } }); final Button patchButton = (Button) findViewById(R.id.patchButton); patchButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Globals.mode = false; Intent intent = new Intent(staticThis, FileBrowserActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); startActivityForResult(intent, 1); } }); final ImageButton bkHelp = (ImageButton) findViewById(R.id.backupHelp); bkHelp.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { AlertDialog dialog = new AlertDialog.Builder(staticThis).create(); dialog.setTitle(getResources().getString(R.string.bkup_rom)); dialog.setMessage(getResources().getString(R.string.bkup_rom_desc)); dialog.setCancelable(true); dialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(android.R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { } }); dialog.show(); } }); final ImageButton altNameHelp = (ImageButton) findViewById(R.id.outfileHelp); altNameHelp.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { AlertDialog dialog = new AlertDialog.Builder(staticThis).create(); dialog.setTitle(getResources().getString(R.string.rename1)); dialog.setMessage(getResources().getString(R.string.rename_desc)); dialog.setCancelable(true); dialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(android.R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { } }); dialog.show(); } }); final ImageButton chkHelp = (ImageButton) findViewById(R.id.ignoreHelp); chkHelp.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { AlertDialog dialog = new AlertDialog.Builder(staticThis).create(); dialog.setTitle(getResources().getString(R.string.ignoreChks)); dialog.setMessage(getResources().getString(R.string.ignoreChks_desc)); dialog.setCancelable(true); dialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(android.R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { } }); dialog.show(); } }); InputFilter filter = new InputFilter() { public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { for (int i = start; i < end; i++) { String IC = "*/*\n*\r*\t*\0*\f*`*?***\\*<*>*|*\"*:*"; if (IC.contains("*" + source.charAt(i) + "*")) { return ""; } } return null; } }; ed.setFilters(new InputFilter[] { filter }); c.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (((CheckBox) v).isChecked()) { d.setEnabled(true); if (d.isChecked()) { ed.setEnabled(true); e.setEnabled(true); } } else { d.setEnabled(false); ed.setEnabled(false); e.setEnabled(false); } } }); d.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (((CheckBox) v).isChecked()) { ed.setEnabled(true); e.setEnabled(true); } else { e.setEnabled(false); ed.setEnabled(false); } } }); final Button applyButton = (Button) findViewById(R.id.applyPatch); applyButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Warn about patching archives. if (Globals.fileToPatch.toLowerCase(Locale.US).endsWith(".7z") || Globals.fileToPatch.toLowerCase(Locale.US).endsWith(".zip") || Globals.fileToPatch.toLowerCase(Locale.US).endsWith(".rar")) { AlertDialog dialog = new AlertDialog.Builder(staticThis).create(); dialog.setTitle(getResources().getString(R.string.warning)); dialog.setMessage(getResources().getString(R.string.zip_warning_desc)); dialog.setCancelable(false); dialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(android.R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { patchCheck(); } }); dialog.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(android.R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { Toast t = Toast.makeText(staticThis, getResources().getString(R.string.nopatch), Toast.LENGTH_SHORT); t.show(); } }); dialog.show(); } else { patchCheck(); } } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { // Uggh. requestPermissions(); } }
From source file:com.radiofarda.istgah.MediaNotificationManager.java
private PendingIntent createContentIntent(MediaDescriptionCompat description) { Intent openUI = new Intent(mService, PodcastsActivity.class); openUI.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP); openUI.putExtra(PodcastsActivity.EXTRA_START_FULLSCREEN, true); if (description != null) { openUI.putExtra(PodcastsActivity.EXTRA_CURRENT_MEDIA_DESCRIPTION, description); }//from w w w .j av a2 s. c om return PendingIntent.getActivity(mService, REQUEST_CODE, openUI, PendingIntent.FLAG_CANCEL_CURRENT); }
From source file:ablgroup.daily2.authentification.AuthentificationFragment.java
public void launchMainActivity() { Intent intent = new Intent(AuthentificationFragment.this, MainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP); startActivity(intent);/*w ww. j a v a 2 s . c o m*/ }