List of usage examples for android.app Activity getIntent
public Intent getIntent()
From source file:fr.cobaltians.cobalt.activities.CobaltActivity.java
public void popTo(String controller, String page) { Intent popToIntent = Cobalt.getInstance(this).getIntentForController(controller, page); if (popToIntent != null) { Bundle popToExtras = popToIntent.getBundleExtra(Cobalt.kExtras); String popToActivityClassName = popToExtras.getString(Cobalt.kActivity); try {//from www .j a v a 2 s. c om Class<?> popToActivityClass = Class.forName(popToActivityClassName); boolean popToControllerFound = false; int popToControllerIndex = -1; for (int i = sActivitiesArrayList.size() - 1; i >= 0; i--) { Activity oldActivity = sActivitiesArrayList.get(i); Class<?> oldActivityClass = oldActivity.getClass(); Bundle oldBundle = oldActivity.getIntent().getExtras(); Bundle oldExtras = (oldBundle != null) ? oldBundle.getBundle(Cobalt.kExtras) : null; String oldPage = (oldExtras != null) ? oldExtras.getString(Cobalt.kPage) : null; if (oldPage == null && CobaltActivity.class.isAssignableFrom(oldActivityClass)) { Fragment fragment = ((CobaltActivity) oldActivity).getSupportFragmentManager() .findFragmentById(((CobaltActivity) oldActivity).getFragmentContainerId()); if (fragment != null) { oldExtras = fragment.getArguments(); oldPage = (oldExtras != null) ? oldExtras.getString(Cobalt.kPage) : null; } } if (popToActivityClass.equals(oldActivityClass) && (!CobaltActivity.class .isAssignableFrom(oldActivityClass) || (CobaltActivity.class.isAssignableFrom(oldActivityClass) && page.equals(oldPage)))) { popToControllerFound = true; popToControllerIndex = i; break; } } if (popToControllerFound) { while (popToControllerIndex + 1 <= sActivitiesArrayList.size()) { sActivitiesArrayList.get(popToControllerIndex + 1).finish(); } } else if (Cobalt.DEBUG) Log.w(Cobalt.TAG, TAG + " - popTo: controller " + controller + (page == null ? "" : " with page " + page) + " not found in history. Abort."); } catch (ClassNotFoundException exception) { exception.printStackTrace(); } } else if (Cobalt.DEBUG) Log.e(Cobalt.TAG, TAG + " - popTo: unable to pop to null controller"); }
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);// w w w .ja v a 2 s.c o m } else if (StopwatchService.ACTION_PAUSE_STOPWATCH.equals(action)) { DataModel.getDataModel().pauseStopwatch(); // Consume the intent activity.setIntent(null); } } // 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); }
From source file:org.totschnig.myexpenses.MyApplication.java
/** * @param ctx//from w w w .j ava 2 s. c o m * Activity that should be password protected, can be null if called * from widget provider * @return true if password protection is set, and we have paused for at least * {@link PrefKey#PROTECTION_DELAY_SECONDS} seconds unless we are called * from widget or from an activity called from widget and passwordless * data entry from widget is allowed sets isLocked as a side effect */ public boolean shouldLock(Activity ctx) { boolean isStartFromWidget = ctx == null || ctx.getIntent().getBooleanExtra(AbstractWidget.EXTRA_START_FROM_WIDGET_DATA_ENTRY, false); boolean isProtected = isProtected(); long lastPause = getLastPause(); boolean isPostDelay = System.nanoTime() - lastPause > (PrefKey.PROTECTION_DELAY_SECONDS.getInt(15) * 1000000000L); boolean isDataEntryEnabled = PrefKey.PROTECTION_ENABLE_DATA_ENTRY_FROM_WIDGET.getBoolean(false); if (isProtected && isPostDelay && (!isDataEntryEnabled || !isStartFromWidget)) { setLocked(true); return true; } return false; }
From source file:com.irccloud.android.fragment.UsersListFragment.java
@Override public void onAttach(Activity activity) { super.onAttach(activity); try {/*from w ww. j a v a 2 s.com*/ mListener = (OnUserSelectedListener) activity; } catch (ClassCastException e) { throw new ClassCastException(activity.toString() + " must implement OnUserSelectedListener"); } if (cid == -1) { cid = activity.getIntent().getIntExtra("cid", 0); channel = activity.getIntent().getStringExtra("name"); } }
From source file:org.mozilla.focus.fragment.BrowserFragment.java
private boolean isStartedFromExternalApp() { final Activity activity = getActivity(); if (activity == null) { return false; }//from w w w.jav a 2 s . co m // No SafeIntent needed here because intent.getAction() is safe (SafeIntent simply calls intent.getAction() // without any wrapping): final Intent intent = activity.getIntent(); return intent != null && Intent.ACTION_VIEW.equals(intent.getAction()); }
From source file:org.apache.cordova.filesystemroots.FileSystemRoots.java
@Override public void initialize(CordovaInterface cordova, CordovaWebView webView) { super.initialize(cordova, webView); Activity activity = cordova.getActivity(); Context context = activity.getApplicationContext(); availableFilesystems = new HashMap<String, String>(); availableFilesystems.put("files", context.getFilesDir().getAbsolutePath()); availableFilesystems.put("files-external", context.getExternalFilesDir(null).getAbsolutePath()); availableFilesystems.put("documents", new File(context.getFilesDir(), "Documents").getAbsolutePath()); availableFilesystems.put("sdcard", Environment.getExternalStorageDirectory().getAbsolutePath()); availableFilesystems.put("cache", context.getCacheDir().getAbsolutePath()); availableFilesystems.put("cache-external", context.getExternalCacheDir().getAbsolutePath()); availableFilesystems.put("root", "/"); installedFilesystems = new HashSet<String>(); String filesystemsStr = activity.getIntent().getStringExtra("androidextrafilesystems"); if (filesystemsStr == null) { filesystemsStr = "files,files-external,documents,sdcard,cache,cache-external"; }//from w ww.j ava 2 s. c om String[] filesystems = filesystemsStr.split(","); FileUtils filePlugin = (FileUtils) webView.pluginManager.getPlugin("File"); if (filePlugin != null) { /* Register filesystems in order */ for (String fsName : filesystems) { if (!installedFilesystems.contains(fsName)) { String fsRoot = availableFilesystems.get(fsName); if (fsRoot != null) { File newRoot = new File(fsRoot); if (newRoot.mkdirs() || newRoot.isDirectory()) { filePlugin.registerFilesystem(new LocalFilesystem(fsName, cordova, fsRoot)); installedFilesystems.add(fsName); } else { Log.d(TAG, "Unable to create root dir for fileystem \"" + fsName + "\", skipping"); } } else { Log.d(TAG, "Unrecognized extra filesystem identifier: " + fsName); } } } } else { Log.w(TAG, "File plugin not found; cannot initialize file-system-roots plugin"); } }
From source file:br.com.arlsoft.pushclient.PushClientModule.java
private void checkForExtras() { Activity activity = TiApplication.getAppRootOrCurrentActivity(); if (activity != null) { Intent intent = activity.getIntent(); if (intent != null) { Bundle extras = intent.getExtras(); if (extras != null && !extras.isEmpty() && extras.containsKey(PROPERTY_EXTRAS)) { extras = extras.getBundle(PROPERTY_EXTRAS); HashMap data = PushClientModule.convertBundleToHashMap(extras); data.put("prev_state", "stopped"); PushClientModule.sendMessage(data, PushClientModule.MODE_CLICK); intent.removeExtra(PROPERTY_EXTRAS); }/*from w w w .ja v a2 s . c om*/ } } }
From source file:org.totschnig.myexpenses.MyApplication.java
public void setLastPause(Activity ctx) { if (!isLocked()) { // if we are dealing with an activity called from widget that allows to // bypass password protection, we do not reset last pause // otherwise user could gain unprotected access to the app boolean isDataEntryEnabled = PrefKey.PROTECTION_ENABLE_DATA_ENTRY_FROM_WIDGET.getBoolean(false); boolean isStartFromWidget = ctx.getIntent() .getBooleanExtra(AbstractWidget.EXTRA_START_FROM_WIDGET_DATA_ENTRY, false); if (!isDataEntryEnabled || !isStartFromWidget) { this.mLastPause = System.nanoTime(); }/*from ww w. j av a 2 s . c om*/ } }
From source file:org.cobaltians.cobalt.activities.CobaltActivity.java
public void popTo(String controller, String page, JSONObject data) { Intent popToIntent = Cobalt.getInstance(this).getIntentForController(controller, page); if (popToIntent != null) { Bundle popToExtras = popToIntent.getBundleExtra(Cobalt.kExtras); String popToActivityClassName = popToExtras.getString(Cobalt.kActivity); try {/*from www . j a v a 2 s . c o m*/ Class<?> popToActivityClass = Class.forName(popToActivityClassName); boolean popToControllerFound = false; int popToControllerIndex = -1; for (int i = sActivitiesArrayList.size() - 1; i >= 0; i--) { Activity oldActivity = sActivitiesArrayList.get(i); Class<?> oldActivityClass = oldActivity.getClass(); Bundle oldBundle = oldActivity.getIntent().getExtras(); Bundle oldExtras = (oldBundle != null) ? oldBundle.getBundle(Cobalt.kExtras) : null; String oldPage = (oldExtras != null) ? oldExtras.getString(Cobalt.kPage) : null; if (oldPage == null && CobaltActivity.class.isAssignableFrom(oldActivityClass)) { Fragment fragment = ((CobaltActivity) oldActivity).getSupportFragmentManager() .findFragmentById(((CobaltActivity) oldActivity).getFragmentContainerId()); if (fragment != null) { oldExtras = fragment.getArguments(); oldPage = (oldExtras != null) ? oldExtras.getString(Cobalt.kPage) : null; } } if (popToActivityClass.equals(oldActivityClass) && (!CobaltActivity.class .isAssignableFrom(oldActivityClass) || (CobaltActivity.class.isAssignableFrom(oldActivityClass) && page.equals(oldPage)))) { popToControllerFound = true; popToControllerIndex = i; ((CobaltActivity) oldActivity).setDataNavigation(data); break; } } if (popToControllerFound) { while (popToControllerIndex + 1 < sActivitiesArrayList.size()) { sActivitiesArrayList.get(popToControllerIndex + 1).finish(); } } else if (Cobalt.DEBUG) Log.w(Cobalt.TAG, TAG + " - popTo: controller " + controller + (page == null ? "" : " with page " + page) + " not found in history. Abort."); } catch (ClassNotFoundException exception) { exception.printStackTrace(); } } else if (Cobalt.DEBUG) Log.e(Cobalt.TAG, TAG + " - popTo: unable to pop to null controller"); }