List of usage examples for android.content Intent addFlags
public @NonNull Intent addFlags(@Flags int flags)
From source file:com.notifry.android.SourceList.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: Intent intent = new Intent(this, ChooseAccount.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent);/*www . j av a 2 s . c om*/ return true; case ADD_SOURCE: askForSourceName(); return true; case REFRESH_SERVER: syncWithServer(); return true; } return super.onOptionsItemSelected(item); }
From source file:io.selendroid.ServerInstrumentation.java
public void startActivity(Class activity) { if (activity == null) { SelendroidLogger.log("activity class is empty", new NullPointerException("Activity class to start is null.")); return;//from w w w . j av a2 s . c o m } finishAllActivities(); // start now the new activity Intent intent = new Intent(getTargetContext(), activity); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_REORDER_TO_FRONT | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.setAction(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); Activity a = startActivitySync(intent); }
From source file:com.android.settings.locationprivacy.LocationPrivacyDialog.java
@Override protected void onPause() { System.out.println("onPause"); if (needRestartActivity) { Intent intent = new Intent(this, LocationPrivacyDialog.class); intent.putExtra("app", app); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, 0); Notification noti = new Notification.Builder(this) .setContentTitle(getResources().getString(R.string.lp_notification_title)) .setContentText(getResources().getString(R.string.lp_notification_)) .setSmallIcon(R.drawable.ic_settings_locationprivacy).setContentIntent(pIntent) .setAutoCancel(true).build(); NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); notificationManager.notify(notificationId, noti); }/*from w w w. j a v a 2 s .co m*/ super.onPause(); }
From source file:com.telepromptu.TeleprompterService.java
@Override public int onStartCommand(Intent intent, int flags, int startId) { super.onStartCommand(intent, flags, startId); Log.d(TAG, intent.toUri(0));/*from w ww . ja v a 2 s . c o m*/ if (mLiveCard == null) { Log.d(TAG, "Publishing LiveCard"); mLiveCard = mTimelineManager.createLiveCard(LIVE_CARD_TAG); // Keep track of the callback to remove it before unpublishing. mCallback = new TeleprompterDrawer(this); mLiveCard.setDirectRenderingEnabled(true).getSurfaceHolder().addCallback(mCallback); Intent menuIntent = new Intent(this, MenuActivity.class); menuIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK); mLiveCard.setAction(PendingIntent.getActivity(this, 0, menuIntent, 0)); mLiveCard.publish(PublishMode.REVEAL); Log.d(TAG, "Done publishing LiveCard"); } else { // TODO(alainv): Jump to the LiveCard when API is available. } (new Thread(new Runnable() { @Override public void run() { // String text = "Hi! My name is Waseem Ahmad! I'm a senior studying computer science at Rice University. Today, I'm going to demonstrate an application that my team has created called Telepromptu. It is a Google Glass application that serves as a live automatic teleprompter. The application uses speech recognition to get snippets of text from Google Speech recognition API. Because the speech to text recognition is not fully accurate, our application uses a local subsequence alignment algorithm to match the recognized text with text on the teleprompter."; slides = connect("http://telepromptu.appspot.com/glass?id=" + presentationId); String text = ""; for (Slide slide : slides) { text += slide.notes + " "; } mCallback.mTeleprompterView.setText(text); speechTraverser = new SuperSpeechTraverser(text); } })).start(); startListening(); return START_STICKY; }
From source file:com.groupme.sdk.GroupMeConnect.java
/** * Opens the Android Market to download the GroupMe application. * * @since 1/* w w w.j av a 2s . co m*/ */ public void downloadGroupMeApp() { Intent intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setData(Uri.parse("market://details?id=com.groupme.android")); mContext.startActivity(intent); }
From source file:cw.kop.autobackground.settings.AppSettingsFragment.java
private void restartActivity() { Intent intent = new Intent(appContext, MainActivity.class); intent.putExtra("fragment", 7); intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); appContext.startActivity(intent);/* ww w .j a v a 2 s. c om*/ getActivity().finish(); getActivity().overridePendingTransition(0, 0); }
From source file:com.newtifry.android.SourceList.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: finish();//from w w w . j ava 2 s . co m /* Intent intent = new Intent(this, ChooseAccount.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); */ return true; case ADD_SOURCE: askForSourceName(); return true; case REFRESH_SERVER: syncWithServer(); return true; case PREFERENCES_MENU_ID: Intent intent = new Intent(this, NewtifryPreferenceActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(intent); return true; } return super.onOptionsItemSelected(item); }
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);/*from ww w . ja v a 2 s. co m*/ 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.google.android.testing.nativedriver.server.AndroidNativeDriver.java
/** Start a new activity either in a new task or the current task. */ public void startActivity(Class<?> activityClass) { Intent intent = new Intent(context.getInstrumentation().getContext(), activityClass); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.setAction(Intent.ACTION_MAIN); intent.addCategory(Intent.CATEGORY_LAUNCHER); context.getInstrumentation().startActivitySync(intent); }
From source file:com.fanfou.app.opensource.service.DownloadService.java
@SuppressWarnings("unused") private PendingIntent getInstallPendingIntent(final String fileName) { final String mimeType = MimeTypeMap.getSingleton() .getMimeTypeFromExtension(CommonHelper.getExtension(fileName)); if (mimeType != null) { final Intent intent = new Intent(Intent.ACTION_VIEW); intent.setDataAndType(Uri.fromFile(new File(fileName)), mimeType); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); final PendingIntent pi = PendingIntent.getActivity(this, 0, intent, 0); return pi; }//from w ww . ja v a 2s. c o m return null; }