List of usage examples for android.content Intent FLAG_ACTIVITY_TASK_ON_HOME
int FLAG_ACTIVITY_TASK_ON_HOME
To view the source code for android.content Intent FLAG_ACTIVITY_TASK_ON_HOME.
Click Source Link
From source file:com.example.android.appnavigation.app.ViewFromOtherTaskActivity.java
public void onLaunchOtherTask(View v) { Intent target = new Intent(this, OutsideTaskActivity.class) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_TASK_ON_HOME); startActivity(target);/*from www .j a v a2s. co m*/ }
From source file:com.saarang.samples.apps.iosched.ui.debug.actions.ShowSessionNotificationDebugAction.java
@Override public void run(Context context, Callback callback) { Intent i = new Intent(Intent.ACTION_VIEW, ScheduleContract.Sessions.buildSessionUri("__keynote__")); PendingIntent pi = PendingIntent.getActivity(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT); Intent mapIntent = new Intent(context, UIUtils.getMapActivityClass(context)); mapIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_TASK_ON_HOME); mapIntent.putExtra(BaseMapActivity.EXTRA_ROOM, "keynote"); PendingIntent piMap = TaskStackBuilder.create(context).addNextIntent(mapIntent).getPendingIntent(0, PendingIntent.FLAG_CANCEL_CURRENT); //= PendingIntent.getActivity(context, 0, mapIntent, 0); NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(context) .setContentTitle("test notification").setContentText("yep, this is a test") .setTicker("hey, you got a test") .setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE) .setSmallIcon(com.saarang.samples.apps.iosched.R.drawable.ic_stat_notification).setContentIntent(pi) .setPriority(Notification.PRIORITY_MAX).setAutoCancel(true); notifBuilder.addAction(com.saarang.samples.apps.iosched.R.drawable.ic_map_holo_dark, context.getString(com.saarang.samples.apps.iosched.R.string.title_map), piMap); NotificationCompat.InboxStyle richNotification = new NotificationCompat.InboxStyle(notifBuilder) .setBigContentTitle(context.getResources().getQuantityString( com.saarang.samples.apps.iosched.R.plurals.session_notification_title, 1, 8, 1)); NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(32534, richNotification.build()); }
From source file:com.google.samples.apps.iosched.debug.actions.ShowSessionNotificationDebugAction.java
@Override public void run(Context context, Callback callback) { Intent i = new Intent(Intent.ACTION_VIEW, ScheduleContract.Sessions.buildSessionUri("__keynote__")); PendingIntent pi = PendingIntent.getActivity(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT); Intent mapIntent = new Intent(context, MapActivity.class); mapIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_TASK_ON_HOME); mapIntent.putExtra(MapActivity.EXTRA_ROOM, "keynote"); PendingIntent piMap = TaskStackBuilder.create(context).addNextIntent(mapIntent).getPendingIntent(0, PendingIntent.FLAG_CANCEL_CURRENT); //= PendingIntent.getActivity(context, 0, mapIntent, 0); NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(context) .setContentTitle("test notification").setContentText("yep, this is a test") .setTicker("hey, you got a test") .setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE) .setSmallIcon(R.drawable.ic_stat_notification).setContentIntent(pi) .setPriority(Notification.PRIORITY_MAX).setAutoCancel(true); notifBuilder.addAction(R.drawable.ic_map_holo_dark, context.getString(R.string.title_map), piMap); NotificationCompat.InboxStyle richNotification = new NotificationCompat.InboxStyle(notifBuilder) .setBigContentTitle(//from w w w. ja va 2 s . c om context.getResources().getQuantityString(R.plurals.session_notification_title, 1, 8, 1)); NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(32534, richNotification.build()); }
From source file:com.google.samples.apps.iosched.ui.debug.actions.ShowSessionNotificationDebugAction.java
@Override public void run(Context context, Callback callback) { Intent i = new Intent(Intent.ACTION_VIEW, ScheduleContract.Sessions.buildSessionUri("__keynote__")); PendingIntent pi = PendingIntent.getActivity(context, 0, i, PendingIntent.FLAG_CANCEL_CURRENT); Intent mapIntent = new Intent(context, UIUtils.getMapActivityClass(context)); mapIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_TASK_ON_HOME); mapIntent.putExtra(BaseMapActivity.EXTRA_ROOM, "keynote"); PendingIntent piMap = TaskStackBuilder.create(context).addNextIntent(mapIntent).getPendingIntent(0, PendingIntent.FLAG_CANCEL_CURRENT); //= PendingIntent.getActivity(context, 0, mapIntent, 0); NotificationCompat.Builder notifBuilder = new NotificationCompat.Builder(context) .setContentTitle("test notification").setContentText("yep, this is a test") .setTicker("hey, you got a test") .setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE) .setSmallIcon(R.drawable.ic_stat_notification).setContentIntent(pi) .setPriority(Notification.PRIORITY_MAX).setAutoCancel(true); notifBuilder.addAction(R.drawable.ic_map_holo_dark, context.getString(R.string.title_map), piMap); NotificationCompat.InboxStyle richNotification = new NotificationCompat.InboxStyle(notifBuilder) .setBigContentTitle(//from w w w . j ava2 s. c o m context.getResources().getQuantityString(R.plurals.session_notification_title, 1, 8, 1)); NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); nm.notify(32534, richNotification.build()); }
From source file:com.felkertech.n.cumulustv.activities.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Log.d(TAG, "onCreate"); sm = new DriveSettingsManager(this); ActivityUtils.openIntroIfNeeded(this); final ChannelDatabase channelDatabase = ChannelDatabase.getInstance(MainActivity.this); Fabric.with(this, new Crashlytics()); if (AppUtils.isTV(this)) { // Go to tv activity Intent leanbackIntent = new Intent(this, LeanbackActivity.class); leanbackIntent.setFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME); startActivity(leanbackIntent);//from w ww . j a v a 2 s .c o m } findViewById(R.id.add).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ActivityUtils.openPluginPicker(true, MainActivity.this); } }); findViewById(R.id.view).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { String[] channelnames = channelDatabase.getChannelNames(); if (channelnames.length == 0) { new MaterialDialog.Builder(MainActivity.this).title(R.string.no_channels) .content(R.string.no_channels_find).positiveText(R.string.ok).negativeText(R.string.no) .callback(new MaterialDialog.ButtonCallback() { @Override public void onPositive(MaterialDialog dialog) { super.onPositive(dialog); dialog.cancel(); findViewById(R.id.suggested).performClick(); } }).show(); } else { try { displayChannelPicker(channelDatabase.getJsonChannels(), channelnames); } catch (JSONException e) { e.printStackTrace(); } } } }); findViewById(R.id.view_genres).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // Generate genres Set<String> genreSet = new HashSet<>(); try { for (JsonChannel jsonChannel : channelDatabase.getJsonChannels()) { Collections.addAll(genreSet, jsonChannel.getGenres()); } final String[] genreArray = genreSet.toArray(new String[genreSet.size()]); new MaterialDialog.Builder(MainActivity.this).title(R.string.select_genres).items(genreArray) .itemsCallback(new MaterialDialog.ListCallback() { @Override public void onSelection(MaterialDialog dialog, View itemView, int position, CharSequence text) { // Now only get certain channels String selectedGenre = genreArray[position]; List<JsonChannel> jsonChannelList = new ArrayList<>(); List<String> channelNames = new ArrayList<>(); try { for (JsonChannel jsonChannel : channelDatabase.getJsonChannels()) { if (jsonChannel.getGenresString().contains(selectedGenre)) { jsonChannelList.add(jsonChannel); channelNames .add(jsonChannel.getNumber() + " " + jsonChannel.getName()); } } displayChannelPicker(jsonChannelList, channelNames.toArray(new String[channelNames.size()]), selectedGenre); } catch (JSONException e) { e.printStackTrace(); } } }).show(); } catch (JSONException e) { e.printStackTrace(); } } }); findViewById(R.id.suggested).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ActivityUtils.openSuggestedChannels(MainActivity.this, gapi); } }); findViewById(R.id.gdrive).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { gapi = ActivityUtils.GoogleDrive.connect(MainActivity.this); } }); findViewById(R.id.more_actions).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { moreClick(); } }); }
From source file:ch.bfh.instacircle.service.NetworkService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { // Initializing the dbHelper in order to get access to the database dbHelper = NetworkDbHelper.getInstance(this); // Create a pending intent which will be invoked after tapping on the // Android notification Intent notificationIntent = new Intent(this, NetworkActiveActivity.class); notificationIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); notificationIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); notificationIntent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME); PendingIntent pendingNotificationIntent = PendingIntent.getActivity(this, 0, notificationIntent, notificationIntent.getFlags()); // Setting up the notification which is being displayed Notification.Builder notificationBuilder = new Notification.Builder(this); notificationBuilder.setContentTitle(getResources().getString(R.string.app_name)); notificationBuilder.setContentText("An InstaCircle Chat session is running. Tap to bring in front."); notificationBuilder.setSmallIcon(R.drawable.glyphicons_244_conversation); notificationBuilder.setContentIntent(pendingNotificationIntent); notificationBuilder.setOngoing(true); Notification notification = notificationBuilder.getNotification(); NotificationManager notificationManager = (NotificationManager) getSystemService( Context.NOTIFICATION_SERVICE); notificationManager.notify(TAG, 1, notification); udpBroadcastReceiverThreads = new UDPBroadcastReceiverThread[100]; tcpUnicastReceiverThreads = new TCPUnicastReceiverThread[100]; // starting 100 threads allocating 100 Ports for (int i = 0; i < 50; i++) { udpBroadcastReceiverThreads[i] = new UDPBroadcastReceiverThread(this, i + 12300); tcpUnicastReceiverThreads[i] = new TCPUnicastReceiverThread(this, i + 12300); udpBroadcastReceiverThreads[i].start(); tcpUnicastReceiverThreads[i].start(); }/*from w w w . j a va 2 s .c om*/ // Register a broadcastreceiver in order to get notification from the UI // when a message should be sent LocalBroadcastManager.getInstance(this).registerReceiver(messageSendReceiver, new IntentFilter("messageSend")); // Opening a conversation dbHelper.openConversation(getSharedPreferences(PREFS_NAME, 0).getString("password", "N/A")); // joining the conversation using the identification in the preferences // file joinNetwork(getSharedPreferences(PREFS_NAME, 0).getString("identification", "N/A")); // start the NetworkActiveActivity intent = new Intent(this, NetworkActiveActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_TASK_ON_HOME); startActivity(intent); return super.onStartCommand(intent, flags, startId); }
From source file:com.silentcircle.contacts.activities.ScContactDetailActivity.java
@Override protected void onCreate(Bundle savedState) { super.onCreate(savedState); if (PhoneCapabilityTester.isUsingTwoPanes(this)) { // This activity must not be shown. We have to select the contact in the // PeopleActivity instead ==> Create a forward intent and finish final Intent originalIntent = getIntent(); Intent intent = new Intent(); intent.setAction(originalIntent.getAction()); intent.setDataAndType(originalIntent.getData(), originalIntent.getType()); // If we are launched from the outside, we should create a new task, because the user // can freely navigate the app (this is different from phones, where only the UP button // kicks the user into the full app) if (NavUtils.shouldUpRecreateTask(this, intent)) { intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_TASK_ON_HOME); } else {/*from w w w. ja v a 2s . co m*/ intent.setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS | Intent.FLAG_ACTIVITY_FORWARD_RESULT | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); } intent.setClass(this, ScContactsMainActivity.class); startActivity(intent); finish(); return; } setContentView(R.layout.contact_detail_activity); mContactDetailLayoutController = new ContactDetailLayoutController(this, savedState, getSupportFragmentManager(), null, findViewById(R.id.contact_detail_container), mContactDetailFragmentListener); // We want the UP affordance but no app icon. // Setting HOME_AS_UP, SHOW_TITLE and clearing SHOW_HOME does the trick. ActionBar actionBar = this.getSupportActionBar(); if (actionBar != null) { actionBar.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE, ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME); actionBar.setTitle(""); } Log.i(TAG, getIntent().getData().toString()); }
From source file:com.cloverstudio.spika.GCMIntentService.java
@SuppressWarnings("deprecation") public void triggerNotification(Context context, String message, String fromName, Bundle pushExtras) { if (fromName != null) { final NotificationManager notificationManager = (NotificationManager) getSystemService( NOTIFICATION_SERVICE);/* w ww . ja v a 2 s .c om*/ Notification notification = new Notification(R.drawable.icon_notification, message, System.currentTimeMillis()); notification.number = mNotificationCounter + 1; mNotificationCounter = mNotificationCounter + 1; Intent intent = new Intent(this, SplashScreenActivity.class); intent.replaceExtras(pushExtras); intent.putExtra(Const.PUSH_INTENT, true); intent.setAction(Long.toString(System.currentTimeMillis())); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_FROM_BACKGROUND | Intent.FLAG_ACTIVITY_TASK_ON_HOME); PendingIntent pendingIntent = PendingIntent.getActivity(this, notification.number, intent, PendingIntent.FLAG_UPDATE_CURRENT); notification.setLatestEventInfo(this, context.getString(R.string.app_name), message, pendingIntent); notification.defaults |= Notification.DEFAULT_VIBRATE; notification.defaults |= Notification.DEFAULT_SOUND; notification.flags |= Notification.FLAG_AUTO_CANCEL; String notificationId = Double.toString(Math.random()); notificationManager.notify(notificationId, 0, notification); } }
From source file:com.snappy.GCMIntentService.java
@SuppressWarnings("deprecation") public void triggerNotification(Context context, String message, String fromName, Bundle pushExtras, String messageData) {/*from w w w . j a va2 s . co m*/ if (fromName != null) { final NotificationManager notificationManager = (NotificationManager) getSystemService( NOTIFICATION_SERVICE); Notification notification = new Notification(R.drawable.icon_notification, message, System.currentTimeMillis()); notification.number = mNotificationCounter + 1; mNotificationCounter = mNotificationCounter + 1; Intent intent = new Intent(this, SplashScreenActivity.class); intent.replaceExtras(pushExtras); intent.putExtra(Const.PUSH_INTENT, true); intent.setAction(Long.toString(System.currentTimeMillis())); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_FROM_BACKGROUND | Intent.FLAG_ACTIVITY_TASK_ON_HOME); PendingIntent pendingIntent = PendingIntent.getActivity(this, notification.number, intent, PendingIntent.FLAG_UPDATE_CURRENT); notification.setLatestEventInfo(this, context.getString(R.string.app_name), messageData, pendingIntent); notification.flags |= Notification.FLAG_AUTO_CANCEL; notification.defaults |= Notification.DEFAULT_VIBRATE; notification.defaults |= Notification.DEFAULT_SOUND; notification.defaults |= Notification.DEFAULT_LIGHTS; String notificationId = Double.toString(Math.random()); notificationManager.notify(notificationId, 0, notification); } Log.i(LOG_TAG, message); Log.i(LOG_TAG, fromName); }
From source file:org.gluu.super_gluu.app.activities.MainActivity.java
public void loadGluuMainActivity() { SharedPreferences preferences = getApplicationContext().getSharedPreferences("PinCodeSettings", Context.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); editor.putBoolean("isMainActivityDestroyed", false); editor.apply();/*from w w w . java 2s . c o m*/ Intent intent = new Intent(this, GluuMainActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_TASK_ON_HOME); startActivity(intent); this.finish(); }