List of usage examples for android.app Activity setIntent
public void setIntent(Intent newIntent)
From source file:com.google.samples.apps.iosched.util.UIUtils.java
/** * If an activity's intent is for a Google I/O web URL that the app can handle natively, this * method translates the intent to the equivalent native intent. *///from w ww . ja v a 2 s .c o m public static void tryTranslateHttpIntent(Activity activity) { Intent intent = activity.getIntent(); if (intent == null) { return; } Uri uri = intent.getData(); if (uri == null || TextUtils.isEmpty(uri.getPath())) { return; } Uri sessionDetailWebUrlPrefix = Uri.parse(Config.SESSION_DETAIL_WEB_URL_PREFIX); String prefixPath = sessionDetailWebUrlPrefix.getPath(); String path = uri.getPath(); if (sessionDetailWebUrlPrefix.getScheme().equals(uri.getScheme()) && sessionDetailWebUrlPrefix.getHost().equals(uri.getHost()) && path.startsWith(prefixPath)) { String sessionId = path.substring(prefixPath.length()); activity.setIntent( new Intent(Intent.ACTION_VIEW, ScheduleContract.Sessions.buildSessionUri(sessionId))); } }
From source file:com.androidinspain.deskclock.stopwatch.StopwatchFragment.java
@Override public void onStart() { super.onStart(); final Activity activity = getActivity(); final Intent intent = activity.getIntent(); if (intent != null) { final String action = intent.getAction(); if (StopwatchService.ACTION_START_STOPWATCH.equals(action)) { DataModel.getDataModel().startStopwatch(); // Consume the intent activity.setIntent(null); } else if (StopwatchService.ACTION_PAUSE_STOPWATCH.equals(action)) { DataModel.getDataModel().pauseStopwatch(); // Consume the intent activity.setIntent(null);//from w ww . j a v a2s .c om } } // Conservatively assume the data in the adapter has changed while the fragment was paused. mLapsAdapter.notifyDataSetChanged(); // Synchronize the user interface with the data model. updateUI(FAB_AND_BUTTONS_IMMEDIATE); // Start watching for page changes away from this fragment. UiDataModel.getUiDataModel().addTabListener(mTabWatcher); }