List of usage examples for android.content Intent FLAG_ACTIVITY_BROUGHT_TO_FRONT
int FLAG_ACTIVITY_BROUGHT_TO_FRONT
To view the source code for android.content Intent FLAG_ACTIVITY_BROUGHT_TO_FRONT.
Click Source Link
From source file:android.security.cts.BrowserTest.java
/** * Verify that no state is preserved across multiple intents sent * to the browser when we run out of usable browser tabs. If such data is * preserved, then browser is vulnerable to a data stealing attack. * * In this test, we send 20 intents to the Android browser. Each * intent sets the variable "document.b1" equal to 1. If we are able * read document.b1 in subsequent invocations of the intent, then * we know state was preserved. In that case, we send a message * to the local server, recording this fact. * * Our test fails if the local server ever receives an HTTP request. * * See http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2011-2357 for * vulnerability information this test case. * * See commits 096bae248453abe83cbb2e5a2c744bd62cdb620b and * afa4ab1e4c1d645e34bd408ce04cadfd2e5dae1e for patches for above vulnerability. *///from w ww . j a va2s. c o m public void testTabExhaustion() throws InterruptedException { List<Intent> intents = getAllJavascriptIntents(); for (Intent i : intents) { i.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT); /* * Send 20 intents. 20 is greater than the maximum number * of tabs allowed by the Android browser. */ for (int j = 0; j < 20; j++) { mContext.startActivity(i); } /* * Wait 5 seconds for the browser to contact the server, but * fail fast if we detect the bug */ for (int j = 0; j < 5; j++) { assertEquals( "javascript handler preserves state across " + "multiple intents. Vulnerable to CVE-2011-2357?", 0, mWebServer.getRequestCount()); Thread.sleep(1000); } } }
From source file:ufms.br.com.ufmsapp.activity.DetalhesEventoActivity.java
public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: Intent parentIntent = NavUtils.getParentActivityIntent(this); //parentIntent.putExtra("NAV_VALUE", getIntent().getIntExtra("NAV_UP", -1)); parentIntent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); startActivity(parentIntent);/* www . jav a 2 s .co m*/ supportFinishAfterTransition(); return true; } return super.onOptionsItemSelected(item); }
From source file:sg.togoparts.gcm.GcmIntentService.java
private void sendNotification(Bundle bundle) { msg = bundle.getString("msg"); String loc = bundle.getString("loc"); title = bundle.getString("title"); String icon = bundle.getString("ico"); String name = bundle.getString("name"); String opt_val = bundle.getString("opt_val"); PendingIntent pendingIntent;//from w w w.j a v a 2 s .c o m Intent notificationIntent = new Intent(); // notificationIntent.setAction(Intent.ACTION_MAIN); // notificationIntent.addCategory(Intent.CATEGORY_LAUNCHER); notificationIntent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT); if (loc.equalsIgnoreCase("home")) { notificationIntent.setClass(this, TabsActivityMain.class); pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT); mNotificationId = HOME_ID; } else { TaskStackBuilder stackBuilder = TaskStackBuilder.create(this); if (loc.equalsIgnoreCase("list_ads")) { notificationIntent.setClass(this, SearchResultActivity.class); notificationIntent.putExtra(FilterActivity.PARAM, opt_val); stackBuilder.addParentStack(SearchResultActivity.class); mNotificationId = LIST_ID; } else if (loc.equalsIgnoreCase("shop")) { notificationIntent.setClass(this, BikeShopDetail.class); notificationIntent.putExtra(Const.SHOP_ID, opt_val); stackBuilder.addParentStack(BikeShopDetail.class); mNotificationId = SHOP_ID; } else if (loc.equalsIgnoreCase("mp_ad")) { notificationIntent.setClass(this, DetailActivity.class); notificationIntent.putExtra(Const.ADS_ID, opt_val); stackBuilder.addParentStack(DetailActivity.class); mNotificationId = AD_ID; } else if (loc.equalsIgnoreCase("link")) { notificationIntent = new Intent(Intent.ACTION_VIEW); notificationIntent.setData(Uri.parse(opt_val)); mNotificationId = LINK_ID; } stackBuilder.addNextIntent(notificationIntent); pendingIntent = stackBuilder.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT); } // notifiy the notification using NotificationManager NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(GcmIntentService.this) .setSmallIcon(R.drawable.ic_launcher).setContentTitle(title).setContentText(msg) .setContentIntent(pendingIntent); // NotificationManager mNotificationManager = // (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); // // mId allows you to update the notification later on. // mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build()); DownloadImageTask download = new DownloadImageTask(mBuilder); download.execute(icon); }
From source file:ufms.br.com.ufmsapp.activity.NotasAtividadesActivity.java
public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: Intent parentIntent = NavUtils.getParentActivityIntent(this); parentIntent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); startActivity(parentIntent);/*ww w . ja v a 2 s . c om*/ supportFinishAfterTransition(); break; case R.id.action_desempenho: Intent intent = new Intent(this, GraficosActivity.class); intent.putExtra(DISCIPLINA_EXTRA, disciplina); startActivity(intent); break; //return true; } return super.onOptionsItemSelected(item); }
From source file:ufms.br.com.ufmsapp.activity.DetalhesDisciplinaActivity.java
public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: Intent parentIntent = NavUtils.getParentActivityIntent(this); parentIntent.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT); startActivity(parentIntent);/*from w w w .j a v a 2s . c om*/ supportFinishAfterTransition(); return true; } return super.onOptionsItemSelected(item); }
From source file:com.stanleyidesis.quotograph.api.controller.LWQNotificationControllerImpl.java
@Override public void postNewWallpaperNotification() { dismissWallpaperGenerationFailureNotification(); final LWQWallpaperController wallpaperController = LWQWallpaperControllerHelper.get(); // Compress background to reasonable Square size final Bitmap backgroundImage = wallpaperController.getBackgroundImage(); if (backgroundImage == null) { return;//from ww w .j a v a 2 s .com } final Bitmap notificationBitmap = chopToCenterSquare(backgroundImage); Context context = LWQApplication.get(); // Establish basic options NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context); notificationBuilder.setAutoCancel(true); notificationBuilder.setCategory(Notification.CATEGORY_SERVICE); notificationBuilder.setColor(LWQApplication.get().getResources().getColor(R.color.palette_A100)); notificationBuilder.setContentInfo(wallpaperController.getAuthor()); notificationBuilder.setContentTitle(context.getString(R.string.new_quotograph)); notificationBuilder.setContentText(String.format("\"%s\"", wallpaperController.getQuote())); notificationBuilder.setLights(LWQApplication.get().getResources().getColor(R.color.palette_A100), 500, 500); notificationBuilder.setLargeIcon(notificationBitmap); notificationBuilder.setOngoing(false); notificationBuilder.setShowWhen(false); notificationBuilder.setSmallIcon(R.mipmap.ic_stat); notificationBuilder.setTicker(String.format("New quote from %s", wallpaperController.getAuthor())); notificationBuilder.setWhen(System.currentTimeMillis()); // Create BigTextStyle NotificationCompat.BigTextStyle bigTextStyle = new NotificationCompat.BigTextStyle(); bigTextStyle.bigText(wallpaperController.getQuote()); bigTextStyle.setBigContentTitle(wallpaperController.getAuthor()); bigTextStyle.setSummaryText(context.getString(R.string.new_quotograph)); notificationBuilder.setStyle(bigTextStyle); // Set Content Intent Intent mainIntent = new Intent(context, LWQActivateActivity.class); mainIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT); notificationBuilder .setContentIntent(PendingIntent.getActivity(context, uniqueRequestCode++, mainIntent, 0)); // Add Share Action Intent shareIntent = new Intent(context, LWQReceiver.class); shareIntent.setAction(context.getString(R.string.action_share)); shareIntent.setData(Uri.parse(AnalyticsUtils.URI_SHARE_SOURCE_NOTIFICATION)); final PendingIntent shareBroadcast = PendingIntent.getBroadcast(context, uniqueRequestCode++, shareIntent, 0); final NotificationCompat.Action shareAction = new NotificationCompat.Action.Builder(R.mipmap.ic_share_white, context.getString(R.string.share), shareBroadcast).build(); notificationBuilder.addAction(shareAction); // Add save to disk Intent saveToDiskIntent = new Intent(context, LWQSaveWallpaperActivity.class); saveToDiskIntent.setData(Uri.parse(AnalyticsUtils.URI_SAVE_SOURCE_NOTIFICATION)); final PendingIntent saveToDiskActivity = PendingIntent.getActivity(context, uniqueRequestCode++, saveToDiskIntent, 0); final NotificationCompat.Action saveToDiskAction = new NotificationCompat.Action.Builder( R.mipmap.ic_save_white, context.getString(R.string.save_to_disk), saveToDiskActivity).build(); notificationBuilder.addAction(saveToDiskAction); // Add Skip Action Intent skipIntent = new Intent(context, LWQReceiver.class); skipIntent.setAction(context.getString(R.string.action_change_wallpaper)); // Track where the skip originated skipIntent.setData(Uri.parse(AnalyticsUtils.URI_CHANGE_SOURCE_NOTIFICATION)); final PendingIntent skipBroadcast = PendingIntent.getBroadcast(context, uniqueRequestCode++, skipIntent, PendingIntent.FLAG_UPDATE_CURRENT); final NotificationCompat.Action skipAction = new NotificationCompat.Action.Builder( R.mipmap.ic_skip_next_white, context.getString(R.string.skip), skipBroadcast).build(); notificationBuilder.addAction(skipAction); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); notificationManager.notify(NOTIF_ID_PRIMARY, notificationBuilder.build()); notificationBitmap.recycle(); }
From source file:org.peercast.core.NotificationHelper.java
public void run() { //Log.d(TAG, "update"); Channel ch = getReceivingChannel(); if (ch != null) { // ?????// w w w. ja va2s . c o m NotificationCompat.Builder nb = createDefaultNotification(); ChannelInfo info = ch.getInfo(); String title = "Playing: " + info.getName(); String text = info.getDesc() + " " + info.getComment(); // ? Stats stats = Stats.fromNativeResult(mService.nativeGetStats()); String sStats = String.format("R % 2d / S % 2d kbps", stats.getInBytes() / 1024 * 8, stats.getOutBytes() / 1024 * 8); // ? nb.setContentTitle(title).setContentText(text).setContentInfo(sStats); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) { //????? Intent iPlay = new Intent(Intent.ACTION_VIEW, Util.getStreamUrl(ch, mService.getRunningPort())); iPlay.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT); PendingIntent piPlay = PendingIntent.getActivity(mService, 0, iPlay, 0); nb.setContentIntent(piPlay); // JB????? [???]? addContactAction(nb, ch); addBumpAction(nb, ch); addDisconnectAction(nb, ch); } else { // ICS???????URL??? nb.setContentIntent(createContactPendingIntent(ch)); } nb.setPriority(NotificationCompat.PRIORITY_HIGH); if (mIsForeground) { mNotificationManager.notify(NOTIFY_ID, nb.build()); } else { mService.startForeground(NOTIFY_ID, nb.build()); mIsForeground = true; } } else { //? if (!mIsForeground) return; mIsForeground = false; // ??????Foreground mNotificationManager.cancel(NOTIFY_ID); mService.stopForeground(true); //bindService?startService???????? //startService??? mService.stopSelf(); } }
From source file:cm.aptoide.pt.DownloadQueueService.java
private void setNotification(int apkidHash, int progress) { String apkid = notifications.get(apkidHash).get("apkid"); int size = Integer.parseInt(notifications.get(apkidHash).get("intSize")); String version = notifications.get(apkidHash).get("version"); RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.download_notification); contentView.setImageViewResource(R.id.download_notification_icon, R.drawable.ic_notification); contentView.setTextViewText(R.id.download_notification_name, getString(R.string.download_alrt) + " " + apkid + " v." + version); contentView.setProgressBar(R.id.download_notification_progress_bar, size * KBYTES_TO_BYTES, progress, false);//w ww . j av a2s .c o m Intent onClick = new Intent(); onClick.setClassName("cm.aptoide.pt", "cm.aptoide.pt"); onClick.setFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT | Intent.FLAG_ACTIVITY_NEW_TASK); onClick.setAction("cm.aptoide.pt.FROM_NOTIFICATION"); // The PendingIntent to launch our activity if the user selects this notification PendingIntent onClickAction = PendingIntent.getActivity(context, 0, onClick, 0); Notification notification = new Notification(R.drawable.ic_notification, getString(R.string.download_alrt) + " " + apkid, System.currentTimeMillis()); notification.flags |= Notification.FLAG_NO_CLEAR | Notification.FLAG_ONGOING_EVENT; notification.contentView = contentView; // Set the info for the notification panel. notification.contentIntent = onClickAction; // notification.setLatestEventInfo(this, getText(R.string.app_name), getText(R.string.add_repo_text), contentIntent); notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); // Send the notification. // We use the position because it is a unique number. We use it later to cancel. notificationManager.notify(apkidHash, notification); // Log.d("Aptoide-DownloadQueueService", "Notification Set"); }
From source file:com.fvd.nimbus.MainActivity.java
public static void createShortcut(Context context) { Intent shortcutIntent = new Intent(context, MainActivity.class); shortcutIntent.setAction(Intent.ACTION_MAIN); shortcutIntent.addFlags(Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT); Intent addIntent = new Intent(); addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, shortcutIntent); addIntent.putExtra(Intent.EXTRA_SHORTCUT_NAME, "Nimbus Clipper"); addIntent.putExtra(Intent.EXTRA_SHORTCUT_ICON_RESOURCE, Intent.ShortcutIconResource.fromContext(context, R.drawable.app_icon)); addIntent.putExtra("duplicate", false); addIntent.setAction("com.android.launcher.action.UNINSTALL_SHORTCUT"); context.sendBroadcast(addIntent);/*from w ww.j av a 2s .co m*/ addIntent.setAction("com.android.launcher.action.INSTALL_SHORTCUT"); context.sendBroadcast(addIntent); }
From source file:com.aware.plugin.polarhrm.Plugin.java
@Override public void onCreate() { super.onCreate(); TAG = "PolarHRM"; CONTEXT_PRODUCER = new Aware_Plugin.ContextProducer() { @Override/*from w ww .ja va 2 s . c om*/ public void onContext() { Intent heartRate = new Intent(ACTION_AWARE_POLAR_HEARTRATE); sendBroadcast(heartRate); } }; DATABASE_TABLES = PolarHRM_Provider.DATABASE_TABLES; TABLES_FIELDS = PolarHRM_Provider.TABLES_FIELDS; CONTEXT_URIS = new Uri[] { PolarHRM_Data.CONTENT_URI, PolarHRM_Profile.CONTENT_URI }; notManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); notificationBuilder = new NotificationCompat.Builder(this); IntentFilter filter = new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED); registerReceiver(btStateListener, filter); prefs = getSharedPreferences(getPackageName(), MODE_MULTI_PROCESS); if (btAdapter != null && !btAdapter.isEnabled()) { Intent makeEnabled = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE); makeEnabled.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT); startActivity(makeEnabled); } updater = new Timer(); updater.scheduleAtFixedRate(updateHR, 0, 2000); if (!prefs.contains("age")) { Intent hrm_params = new Intent(getApplicationContext(), Settings.class); hrm_params.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(hrm_params); } else { algorithm = new Algorithm(prefs.getInt("age", 25), prefs.getInt("rhr", 70)); SparseArray<double[]> hr_zones = algorithm.getZones(); ContentValues rowData = new ContentValues(); rowData.put(PolarHRM_Profile.TIMESTAMP, System.currentTimeMillis()); rowData.put(PolarHRM_Profile.DEVICE_ID, Aware.getSetting(getContentResolver(), Aware_Preferences.DEVICE_ID)); rowData.put(PolarHRM_Profile.AGE, prefs.getInt("age", 25)); rowData.put(PolarHRM_Profile.RESTING_HR, prefs.getInt("rhr", 70)); rowData.put(PolarHRM_Profile.RECOVERY_MIN, hr_zones.get(0)[0]); rowData.put(PolarHRM_Profile.RECOVERY_MAX, hr_zones.get(0)[1]); rowData.put(PolarHRM_Profile.AEROBIC_MIN, hr_zones.get(1)[0]); rowData.put(PolarHRM_Profile.AEROBIC_MAX, hr_zones.get(1)[1]); rowData.put(PolarHRM_Profile.ANAEROBIC_MIN, hr_zones.get(2)[0]); rowData.put(PolarHRM_Profile.ANAEROBIC_MAX, hr_zones.get(2)[1]); rowData.put(PolarHRM_Profile.RED_LINE_MIN, hr_zones.get(3)[0]); rowData.put(PolarHRM_Profile.RED_LINE_MAX, hr_zones.get(3)[1]); getContentResolver().insert(PolarHRM_Profile.CONTENT_URI, rowData); } showUI(); }