List of usage examples for android.content Intent ACTION_SEARCH
String ACTION_SEARCH
To view the source code for android.content Intent ACTION_SEARCH.
Click Source Link
From source file:com.android.calendar.SearchActivity.java
private void handleIntent(Intent intent) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra(SearchManager.QUERY); search(query, null);/* ww w .j a v a2s .c om*/ } }
From source file:app.cloud9.com.cloud9.NoticeBoard.java
private void handleIntent(Intent intent) { if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra(SearchManager.QUERY); //use the query to search your data somehow }//from w w w . j a v a2 s . com }
From source file:com.hybris.mobile.app.commerce.fragment.CatalogContentFragmentBase.java
/** * Return true if we come from a search request * * @return//from w ww.ja v a 2 s . c om */ protected boolean isSearchRequest() { Intent intent = getActivity().getIntent(); return (intent != null && StringUtils.equals(Intent.ACTION_SEARCH, intent.getAction()) && intent.hasExtra(SearchManager.QUERY)) || StringUtils.isNotBlank(mCurrentSearchText); }
From source file:com.jefftharris.passwdsafe.PasswdSafe.java
@Override protected void onNewIntent(Intent intent) { super.onNewIntent(intent); PasswdSafeUtil.dbginfo(TAG, "onNewIntent: %s", intent); switch (intent.getAction()) { case PasswdSafeUtil.VIEW_INTENT: case Intent.ACTION_VIEW: { final Uri openUri = PasswdSafeApp.getOpenUriFromIntent(intent); final ObjectHolder<Boolean> reopen = new ObjectHolder<>(true); itsFileDataFrag.useFileData(new PasswdFileDataUser() { @Override// w w w. j a v a 2 s. c o m public void useFileData(@NonNull PasswdFileData fileData) { reopen.set(!fileData.getUri().getUri().equals(openUri)); } }); Boolean reopenVal = reopen.get(); if ((reopenVal != null) && reopenVal) { // Close and reopen the new file itsFileDataFrag.setFileData(null); doUpdateView(ViewMode.INIT, new PasswdLocation()); changeInitialView(); changeFileOpenView(intent); } break; } case Intent.ACTION_SEARCH: { setRecordQueryFilter(intent.getStringExtra(SearchManager.QUERY)); break; } default: { FragmentManager fragMgr = getSupportFragmentManager(); Fragment frag = fragMgr.findFragmentById(R.id.content); if (frag instanceof PasswdSafeOpenFileFragment) { ((PasswdSafeOpenFileFragment) frag).onNewIntent(intent); } break; } } }
From source file:com.hughes.android.dictionary.DictionaryActivity.java
@Override public void onCreate(Bundle savedInstanceState) { // This needs to be before super.onCreate, otherwise ActionbarSherlock // doesn't makes the background of the actionbar white when you're // in the dark theme. setTheme(((DictionaryApplication) getApplication()).getSelectedTheme().themeId); Log.d(LOG, "onCreate:" + this); super.onCreate(savedInstanceState); final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); // Don't auto-launch if this fails. prefs.edit().remove(C.DICT_FILE).commit(); setContentView(R.layout.dictionary_activity); application = (DictionaryApplication) getApplication(); theme = application.getSelectedTheme(); textColorFg = getResources().getColor(theme.tokenRowFgColor); final Intent intent = getIntent(); String intentAction = intent.getAction(); /**//from w w w .ja v a 2 s .co m * @author Dominik Kppl Querying the Intent * com.hughes.action.ACTION_SEARCH_DICT is the advanced query * Arguments: SearchManager.QUERY -> the phrase to search from * -> language in which the phrase is written to -> to which * language shall be translated */ if (intentAction != null && intentAction.equals("com.hughes.action.ACTION_SEARCH_DICT")) { String query = intent.getStringExtra(SearchManager.QUERY); String from = intent.getStringExtra("from"); if (from != null) from = from.toLowerCase(Locale.US); String to = intent.getStringExtra("to"); if (to != null) to = to.toLowerCase(Locale.US); if (query != null) { getIntent().putExtra(C.SEARCH_TOKEN, query); } if (intent.getStringExtra(C.DICT_FILE) == null && (from != null || to != null)) { Log.d(LOG, "DictSearch: from: " + from + " to " + to); List<DictionaryInfo> dicts = application.getDictionariesOnDevice(null); for (DictionaryInfo info : dicts) { boolean hasFrom = from == null; boolean hasTo = to == null; for (IndexInfo index : info.indexInfos) { if (!hasFrom && index.shortName.toLowerCase(Locale.US).equals(from)) hasFrom = true; if (!hasTo && index.shortName.toLowerCase(Locale.US).equals(to)) hasTo = true; } if (hasFrom && hasTo) { if (from != null) { int which_index = 0; for (; which_index < info.indexInfos.size(); ++which_index) { if (info.indexInfos.get(which_index).shortName.toLowerCase(Locale.US).equals(from)) break; } intent.putExtra(C.INDEX_SHORT_NAME, info.indexInfos.get(which_index).shortName); } intent.putExtra(C.DICT_FILE, application.getPath(info.uncompressedFilename).toString()); break; } } } } /** * @author Dominik Kppl Querying the Intent Intent.ACTION_SEARCH is a * simple query Arguments follow from android standard (see * documentation) */ if (intentAction != null && intentAction.equals(Intent.ACTION_SEARCH)) { String query = intent.getStringExtra(SearchManager.QUERY); if (query != null) getIntent().putExtra(C.SEARCH_TOKEN, query); } /** * @author Dominik Kppl If no dictionary is chosen, use the default * dictionary specified in the preferences If this step does * fail (no default directory specified), show a toast and * abort. */ if (intent.getStringExtra(C.DICT_FILE) == null) { String dictfile = prefs.getString(getString(R.string.defaultDicKey), null); if (dictfile != null) intent.putExtra(C.DICT_FILE, application.getPath(dictfile).toString()); } String dictFilename = intent.getStringExtra(C.DICT_FILE); if (dictFilename == null) { Toast.makeText(this, getString(R.string.no_dict_file), Toast.LENGTH_LONG).show(); startActivity(DictionaryManagerActivity.getLaunchIntent(getApplicationContext())); finish(); return; } if (dictFilename != null) dictFile = new File(dictFilename); ttsReady = false; textToSpeech = new TextToSpeech(getApplicationContext(), new OnInitListener() { @Override public void onInit(int status) { ttsReady = true; updateTTSLanguage(indexIndex); } }); try { final String name = application.getDictionaryName(dictFile.getName()); this.setTitle("QuickDic: " + name); dictRaf = new RandomAccessFile(dictFile, "r"); dictionary = new Dictionary(dictRaf); } catch (Exception e) { Log.e(LOG, "Unable to load dictionary.", e); if (dictRaf != null) { try { dictRaf.close(); } catch (IOException e1) { Log.e(LOG, "Unable to close dictRaf.", e1); } dictRaf = null; } Toast.makeText(this, getString(R.string.invalidDictionary, "", e.getMessage()), Toast.LENGTH_LONG) .show(); startActivity(DictionaryManagerActivity.getLaunchIntent(getApplicationContext())); finish(); return; } String targetIndex = intent.getStringExtra(C.INDEX_SHORT_NAME); if (savedInstanceState != null && savedInstanceState.getString(C.INDEX_SHORT_NAME) != null) { targetIndex = savedInstanceState.getString(C.INDEX_SHORT_NAME); } indexIndex = 0; for (int i = 0; i < dictionary.indices.size(); ++i) { if (dictionary.indices.get(i).shortName.equals(targetIndex)) { indexIndex = i; break; } } Log.d(LOG, "Loading index " + indexIndex); index = dictionary.indices.get(indexIndex); setListAdapter(new IndexAdapter(index)); // Pre-load the collators. new Thread(new Runnable() { public void run() { android.os.Process.setThreadPriority(android.os.Process.THREAD_PRIORITY_BACKGROUND); final long startMillis = System.currentTimeMillis(); try { TransliteratorManager.init(new TransliteratorManager.Callback() { @Override public void onTransliteratorReady() { uiHandler.post(new Runnable() { @Override public void run() { onSearchTextChange(searchView.getQuery().toString()); } }); } }); for (final Index index : dictionary.indices) { final String searchToken = index.sortedIndexEntries.get(0).token; final IndexEntry entry = index.findExact(searchToken); if (entry == null || !searchToken.equals(entry.token)) { Log.e(LOG, "Couldn't find token: " + searchToken + ", " + (entry == null ? "null" : entry.token)); } } indexPrepFinished = true; } catch (Exception e) { Log.w(LOG, "Exception while prepping. This can happen if dictionary is closed while search is happening."); } Log.d(LOG, "Prepping indices took:" + (System.currentTimeMillis() - startMillis)); } }).start(); String fontName = prefs.getString(getString(R.string.fontKey), "FreeSerif.otf.jpg"); if ("SYSTEM".equals(fontName)) { typeface = Typeface.DEFAULT; } else if ("SERIF".equals(fontName)) { typeface = Typeface.SERIF; } else if ("SANS_SERIF".equals(fontName)) { typeface = Typeface.SANS_SERIF; } else if ("MONOSPACE".equals(fontName)) { typeface = Typeface.MONOSPACE; } else { if ("FreeSerif.ttf.jpg".equals(fontName)) { fontName = "FreeSerif.otf.jpg"; } try { typeface = Typeface.createFromAsset(getAssets(), fontName); } catch (Exception e) { Log.w(LOG, "Exception trying to use typeface, using default.", e); Toast.makeText(this, getString(R.string.fontFailure, e.getLocalizedMessage()), Toast.LENGTH_LONG) .show(); } } if (typeface == null) { Log.w(LOG, "Unable to create typeface, using default."); typeface = Typeface.DEFAULT; } final String fontSize = prefs.getString(getString(R.string.fontSizeKey), "14"); try { fontSizeSp = Integer.parseInt(fontSize.trim()); } catch (NumberFormatException e) { fontSizeSp = 14; } // ContextMenu. registerForContextMenu(getListView()); // Cache some prefs. wordList = application.getWordListFile(); saveOnlyFirstSubentry = prefs.getBoolean(getString(R.string.saveOnlyFirstSubentryKey), false); clickOpensContextMenu = prefs.getBoolean(getString(R.string.clickOpensContextMenuKey), false); Log.d(LOG, "wordList=" + wordList + ", saveOnlyFirstSubentry=" + saveOnlyFirstSubentry); onCreateSetupActionBarAndSearchView(); // Set the search text from the intent, then the saved state. String text = getIntent().getStringExtra(C.SEARCH_TOKEN); if (savedInstanceState != null) { text = savedInstanceState.getString(C.SEARCH_TOKEN); } if (text == null) { text = ""; } setSearchText(text, true); Log.d(LOG, "Trying to restore searchText=" + text); setDictionaryPrefs(this, dictFile, index.shortName, searchView.getQuery().toString()); updateLangButton(); searchView.requestFocus(); // http://stackoverflow.com/questions/2833057/background-listview-becomes-black-when-scrolling // getListView().setCacheColorHint(0); }
From source file:com.scrachx.foodfacts.checker.ui.main.MainActivity.java
@Override protected void onNewIntent(Intent intent) { setIntent(intent);/*from w w w .java 2 s.com*/ if (Intent.ACTION_SEARCH.equals(intent.getAction())) { String query = intent.getStringExtra(SearchManager.QUERY); Bundle args = new Bundle(); args.putString("query", query); if (EAN13CheckDigit.EAN13_CHECK_DIGIT.isValid(query) && (!query.substring(0, 3).contains("977") || !query.substring(0, 3).contains("978") || !query.substring(0, 3).contains("979"))) { mPresenter.loadProduct(query); } else { mSearchView.clearFocus(); getSupportFragmentManager().beginTransaction() .replace(R.id.fragment_container, SearchFragment.newInstance(args), SearchFragment.TAG) .commit(); } } }
From source file:com.smedic.tubtub.Pane.java
/** * Options menu in action bar/*from w ww.j a va 2 s . c om*/ * * @param menu * @return */ @Override public boolean onCreateOptionsMenu(Menu menu) { // Inflate the menu; this adds items to the action bar if it is present. getMenuInflater().inflate(R.menu.menu_main, menu); MenuItem searchItem = menu.findItem(R.id.action_search); SearchManager searchManager = (SearchManager) getSystemService(Context.SEARCH_SERVICE); final SearchView searchView = (SearchView) MenuItemCompat.getActionView(searchItem); if (searchView != null) { searchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); } //suggestions final CursorAdapter suggestionAdapter = new SimpleCursorAdapter(this, suggestions, null, new String[] { SearchManager.SUGGEST_COLUMN_TEXT_1 }, new int[] { android.R.id.text1 }, 0); final List<String> suggestions = new ArrayList<>(); searchView.setSuggestionsAdapter(suggestionAdapter); searchView.setOnSuggestionListener(new SearchView.OnSuggestionListener() { @Override public boolean onSuggestionSelect(int position) { return false; } @Override public boolean onSuggestionClick(int position) { searchView.setQuery(suggestions.get(position), false); searchView.clearFocus(); Intent suggestionIntent = new Intent(Intent.ACTION_SEARCH); suggestionIntent.putExtra(SearchManager.QUERY, suggestions.get(position)); handleIntent(suggestionIntent); return true; } }); searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String s) { return false; //if true, no new intent is started } @Override public boolean onQueryTextChange(final String query) { // check network connection. If not available, do not query. // this also disables onSuggestionClick triggering if (query.length() > 2) { //make suggestions after 3rd letter if (networkConf.isNetworkAvailable()) { suggestionLoader(suggestions, suggestionAdapter, query).forceLoad(); return true; } } return false; } }); return true; }
From source file:com.todotxt.todotxttouch.TodoTxtTouch.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); currentActivityPointer = this; setContentView(R.layout.main);/*from w w w.j a v a 2 s . co m*/ m_app = (TodoApplication) getApplication(); m_app.m_prefs.registerOnSharedPreferenceChangeListener(this); this.taskBag = m_app.getTaskBag(); m_adapter = new TaskAdapter(this, R.layout.list_item, taskBag.getTasks(), getLayoutInflater()); // listen to the ACTION_LOGOUT intent, if heard display LoginScreen // and finish() current activity IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Constants.INTENT_ACTION_ARCHIVE); intentFilter.addAction(Constants.INTENT_SYNC_CONFLICT); intentFilter.addAction(Constants.INTENT_ACTION_LOGOUT); intentFilter.addAction(Constants.INTENT_UPDATE_UI); intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); m_broadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (intent.getAction().equalsIgnoreCase(Constants.INTENT_ACTION_ARCHIVE)) { // archive // refresh screen to remove completed tasks // push to remote //archiveTasks(); } else if (intent.getAction().equalsIgnoreCase(Constants.INTENT_ACTION_LOGOUT)) { taskBag.clear(); m_app.broadcastWidgetUpdate(); // Intent i = new Intent(context, LoginScreen.class); // startActivity(i); // finish(); } else if (intent.getAction().equalsIgnoreCase(Constants.INTENT_UPDATE_UI)) { updateSyncUI(intent.getBooleanExtra("redrawList", false)); } else if (intent.getAction().equalsIgnoreCase(Constants.INTENT_SYNC_CONFLICT)) { handleSyncConflict(); } else if (intent.getAction().equalsIgnoreCase(ConnectivityManager.CONNECTIVITY_ACTION)) { handleConnectivityChange(context); } // Taskbag might have changed, update drawer adapter // to reflect new/removed contexts and projects updateNavigationDrawer(); } }; registerReceiver(m_broadcastReceiver, intentFilter); setListAdapter(this.m_adapter); ListView lv = getListView(); lv.setTextFilterEnabled(true); lv.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE); // Setup Navigation drawer m_drawerList = (ListView) findViewById(R.id.left_drawer); m_drawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout); // Set the adapter for the list view updateNavigationDrawer(); SwipeDismissList.OnDismissCallback callback = new SwipeDismissList.OnDismissCallback() { // Gets called whenever the user deletes an item. public SwipeDismissList.Undoable onDismiss(AbsListView listView, final int position) { m_swipeList.setEnabled(false); final Task task = m_adapter.getItem(position); m_adapter.remove(task); ArrayList<Task> tasks = new ArrayList<Task>(); tasks.add(task); final boolean wasComplete = task.isCompleted(); final String popupTitle = listView.getResources() .getString(wasComplete ? R.string.swipe_action_unComplete : R.string.swipe_action_complete); if (wasComplete) { undoCompleteTasks(tasks, false); } else { completeTasks(tasks, false); } // Return an Undoable implementing every method return new SwipeDismissList.Undoable() { // Method is called when user undoes this deletion public void undo() { // Reinsert item to list ArrayList<Task> tasks = new ArrayList<Task>(); tasks.add(task); if (wasComplete) { completeTasks(tasks, false); } else { undoCompleteTasks(tasks, false); } } @Override public String getTitle() { return popupTitle; } }; } }; m_swipeList = new SwipeDismissList(lv, callback, SwipeDismissList.UndoMode.SINGLE_UNDO); m_swipeList.setPopupYOffset(56); m_swipeList.setAutoHideDelay(250); m_swipeList.setSwipeLayout(R.id.swipe_view); m_pullToRefreshAttacher = PullToRefreshAttacher.get(this); DefaultHeaderTransformer ht = (DefaultHeaderTransformer) m_pullToRefreshAttacher.getHeaderTransformer(); ht.setPullText(getString(R.string.pull_to_refresh)); ht.setRefreshingText(getString(R.string.syncing)); m_pullToRefreshAttacher.addRefreshableView(lv, this); // Delegate OnTouch calls to both libraries that want to receive them // Don't forward swipes when swiping on the left lv.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent motionEvent) { // Don't listen to gestures on the left area of the list // to prevent interference with the DrawerLayout ViewConfiguration vc = ViewConfiguration.get(view.getContext()); int deadZoneX = vc.getScaledTouchSlop(); if (motionEvent.getX() < deadZoneX) { return false; } m_pullToRefreshAttacher.onTouch(view, motionEvent); // Only listen to item swipes if we are not scrolling the // listview if (!mListScrolling && m_swipeList.onTouch(view, motionEvent)) { return false; } return false; } }); // We must set the scrollListener after the onTouchListener, // otherwise it will not fire lv.setOnScrollListener(this); initializeTasks(false); // Show search results Intent intent = getIntent(); if (Intent.ACTION_SEARCH.equals(intent.getAction())) { m_app.m_search = intent.getStringExtra(SearchManager.QUERY); Log.v(TAG, "Searched for " + m_app.m_search); m_app.storeFilters(); setFilteredTasks(false); } }
From source file:com.cuddlesoft.nori.SearchActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Request window manager features. supportRequestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS); // Get shared preferences. sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); // Inflate views. setContentView(R.layout.activity_search); // Get search result grid fragment from fragment manager. searchResultGridFragment = (SearchResultGridFragment) getSupportFragmentManager() .findFragmentById(R.id.fragment_searchResultGrid); // If the activity was started from a Search intent, create the SearchClient object and submit search. Intent intent = getIntent();//from w w w .ja va2s . c om if (intent != null && intent.getAction().equals(Intent.ACTION_SEARCH) && searchResultGridFragment.getSearchResult() == null) { SearchClient.Settings searchClientSettings = intent .getParcelableExtra(BUNDLE_ID_SEARCH_CLIENT_SETTINGS); searchClient = searchClientSettings.createSearchClient(); doSearch(intent.getStringExtra(BUNDLE_ID_SEARCH_QUERY)); } // Set up the dropdown API server picker. setUpActionBar(); }
From source file:com.gelakinetic.mtgfam.activities.MainActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /* http://stackoverflow.com/questions/13179620/force-overflow-menu-in-actionbarsherlock/13180285 * /*from w ww. j av a2 s .c o m*/ * Open ActionBarSherlock/src/com/actionbarsherlock/internal/view/menu/ActionMenuPresenter.java, go to method reserveOverflow * Replace the original with: * public static boolean reserveOverflow(Context context) { return true; } */ if (DEVICE_VERSION >= DEVICE_HONEYCOMB) { try { ViewConfiguration config = ViewConfiguration.get(this); Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey"); if (menuKeyField != null) { menuKeyField.setAccessible(true); menuKeyField.setBoolean(config, false); } } catch (Exception ex) { // Ignore } } mFragmentManager = getSupportFragmentManager(); try { pInfo = getPackageManager().getPackageInfo(getPackageName(), 0); } catch (NameNotFoundException e) { pInfo = null; } if (prefAdapter == null) { prefAdapter = new PreferencesAdapter(this); } int lastVersion = prefAdapter.getLastVersion(); if (pInfo.versionCode != lastVersion) { // Clear the robospice cache on upgrade. This way, no cached values w/o foil prices will exist try { spiceManager.removeAllDataFromCache(); } catch (NullPointerException e) { // eat it. tasty } showDialogFragment(CHANGELOGDIALOG); prefAdapter.setLastVersion(pInfo.versionCode); bounceMenu = lastVersion <= 15; //Only bounce if the last version is 1.8.1 or lower (or a fresh install) } File mtr = new File(getFilesDir(), JudgesCornerFragment.MTR_LOCAL_FILE); File ipg = new File(getFilesDir(), JudgesCornerFragment.IPG_LOCAL_FILE); if (!mtr.exists()) { try { InputStream in = getResources().openRawResource(R.raw.mtr); FileOutputStream fos = new FileOutputStream(mtr); IOUtils.copy(in, fos); } catch (FileNotFoundException e) { Log.w("MainActivity", "MTR file could not be copied: " + e.getMessage()); } catch (IOException e) { Log.w("MainActivity", "MTR file could not be copied: " + e.getMessage()); } } if (!ipg.exists()) { try { InputStream in = getResources().openRawResource(R.raw.ipg); FileOutputStream fos = new FileOutputStream(ipg); IOUtils.copy(in, fos); } catch (FileNotFoundException e) { Log.w("MainActivity", "IPG file could not be copied: " + e.getMessage()); } catch (IOException e) { Log.w("MainActivity", "IPG file could not be copied: " + e.getMessage()); } } ActionBar actionBar = getSupportActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setHomeButtonEnabled(true); actionBar.setDisplayShowTitleEnabled(false); actionBar.setIcon(R.drawable.sliding_menu_icon); SlidingMenu slidingMenu = getSlidingMenu(); slidingMenu.setBehindWidthRes(R.dimen.sliding_menu_width); slidingMenu.setBehindScrollScale(0.0f); slidingMenu.setTouchModeAbove(SlidingMenu.TOUCHMODE_FULLSCREEN); slidingMenu.setShadowWidthRes(R.dimen.shadow_width); slidingMenu.setShadowDrawable(R.drawable.sliding_menu_shadow); setSlidingActionBarEnabled(false); setBehindContentView(R.layout.fragment_menu); me = this; boolean autoupdate = prefAdapter.getAutoUpdate(); if (autoupdate) { // Only update the banning list if it hasn't been updated recently long curTime = new Date().getTime(); int updatefrequency = Integer.valueOf(prefAdapter.getUpdateFrequency()); int lastLegalityUpdate = prefAdapter.getLastLegalityUpdate(); // days to ms if (((curTime / 1000) - lastLegalityUpdate) > (updatefrequency * 24 * 60 * 60)) { startService(new Intent(this, DbUpdaterService.class)); } } timerHandler = new Handler(); registerReceiver(endTimeReceiver, new IntentFilter(RoundTimerFragment.RESULT_FILTER)); registerReceiver(startTimeReceiver, new IntentFilter(RoundTimerService.START_FILTER)); registerReceiver(cancelTimeReceiver, new IntentFilter(RoundTimerService.CANCEL_FILTER)); updatingDisplay = false; timeShowing = false; getSlidingMenu().setOnOpenedListener(new OnOpenedListener() { @Override public void onOpened() { // Close the keyboard if the slidingMenu is opened hideKeyboard(); } }); setContentView(R.layout.fragment_activity); getSupportFragmentManager().beginTransaction().replace(R.id.frag_menu, new MenuFragment()).commit(); showOnePane(); if (findViewById(R.id.middle_container) != null) { // The detail container view will be present only in the // large-screen layouts (res/values-large and // res/values-sw600dp). If this view is present, then the // activity should be in two-pane mode. mIsATablet = true; if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { mThreePane = true; } else { mThreePane = false; } } else { mThreePane = false; mIsATablet = false; if (findViewById(R.id.middle_container) != null) { findViewById(R.id.middle_container).setVisibility(View.GONE); findViewById(R.id.right_container).setVisibility(View.GONE); } } Intent intent = getIntent(); if (savedInstanceState == null) { try { if (intent.getAction().equals(Intent.ACTION_VIEW)) { //apparently this can NPE on 4.3. because why not. if we catch it, launch the default frag // handles a click on a search suggestion; launches activity to show word Uri u = intent.getData(); long id = Long.parseLong(u.getLastPathSegment()); // add a fragment Bundle args = new Bundle(); args.putBoolean("isSingle", true); args.putLong("id", id); CardViewFragment rlFrag = new CardViewFragment(); rlFrag.setArguments(args); attachSingleFragment(rlFrag, "left_frag", false, false); showOnePane(); hideKeyboard(); } else if (intent.getAction().equals(Intent.ACTION_SEARCH)) { boolean consolidate = prefAdapter.getConsolidateSearch(); String query = intent.getStringExtra(SearchManager.QUERY); SearchCriteria sc = new SearchCriteria(); sc.Name = query; sc.Set_Logic = (consolidate ? CardDbAdapter.FIRSTPRINTING : CardDbAdapter.ALLPRINTINGS); // add a fragment Bundle args = new Bundle(); args.putBoolean(SearchViewFragment.RANDOM, false); args.putSerializable(SearchViewFragment.CRITERIA, sc); if (mIsATablet) { SearchViewFragment svFrag = new SearchViewFragment(); svFrag.setArguments(args); attachSingleFragment(svFrag, "left_frag", false, false); } else { ResultListFragment rlFrag = new ResultListFragment(); rlFrag.setArguments(args); attachSingleFragment(rlFrag, "left_frag", false, false); } hideKeyboard(); } else if (intent.getAction().equals(ACTION_FULL_SEARCH)) { attachSingleFragment(new SearchViewFragment(), "left_frag", false, false); showOnePane(); } else if (intent.getAction().equals(ACTION_WIDGET_SEARCH)) { attachSingleFragment(new SearchWidgetFragment(), "left_frag", false, false); showOnePane(); } else if (intent.getAction().equals(ACTION_ROUND_TIMER)) { attachSingleFragment(new RoundTimerFragment(), "left_frag", false, false); showOnePane(); } else { launchDefaultFragment(); } } catch (NullPointerException e) { launchDefaultFragment(); } } }