Example usage for android.app SearchManager EXTRA_DATA_KEY

List of usage examples for android.app SearchManager EXTRA_DATA_KEY

Introduction

In this page you can find the example usage for android.app SearchManager EXTRA_DATA_KEY.

Prototype

String EXTRA_DATA_KEY

To view the source code for android.app SearchManager EXTRA_DATA_KEY.

Click Source Link

Document

Intent extra data key: This key will be used for the extra populated by the #SUGGEST_COLUMN_INTENT_EXTRA_DATA column.

Usage

From source file:com.miz.mizuu.MovieDetails.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Set theme/*from  ww w .j a  v a2s. co  m*/
    setTheme(R.style.Mizuu_Theme_NoBackground);

    ViewUtils.setupWindowFlagsForStatusbarOverlay(getWindow(), true);

    setTitle(null);

    // Fetch the database ID of the movie to view
    if (Intent.ACTION_SEARCH.equals(getIntent().getAction())) {
        mMovieId = getIntent().getStringExtra(SearchManager.EXTRA_DATA_KEY);
    } else {
        mMovieId = getIntent().getExtras().getString("tmdbId");
    }

    Fragment frag = getSupportFragmentManager().findFragmentByTag(TAG);
    if (frag == null) {
        final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        ft.add(android.R.id.content, MovieDetailsFragment.newInstance(mMovieId), TAG);
        ft.commit();
    }
}

From source file:com.miz.mizuu.TvShowDetails.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    // Set theme/*from  w  w w.ja  va 2 s  .  co m*/
    setTheme(R.style.Mizuu_Theme_NoBackground);

    ViewUtils.setupWindowFlagsForStatusbarOverlay(getWindow(), true);

    setTitle(null);

    // Fetch the database ID of the TV show to view
    if (Intent.ACTION_SEARCH.equals(getIntent().getAction())) {
        mShowId = getIntent().getStringExtra(SearchManager.EXTRA_DATA_KEY);
    } else {
        mShowId = getIntent().getStringExtra("showId");
    }

    Fragment frag = getSupportFragmentManager().findFragmentByTag(TAG);
    if (frag == null) {
        final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        ft.add(android.R.id.content, TvShowDetailsFragment.newInstance(mShowId), TAG);
        ft.commit();
    }
}

From source file:com.nadmm.airports.afd.SearchActivity.java

private void handleIntent() {
    Intent intent = getIntent();/*from   w  ww. ja  v  a 2  s.  c  o  m*/
    String action = intent.getAction();
    if (Intent.ACTION_SEARCH.equals(action)) {
        // Perform the search using user provided query string
        String query = intent.getStringExtra(SearchManager.QUERY);
        showResults(query);
    } else if (Intent.ACTION_VIEW.equals(action)) {
        // User clicked on a suggestion
        Bundle extra = intent.getExtras();
        String siteNumber = extra.getString(SearchManager.EXTRA_DATA_KEY);
        Intent apt = new Intent(this, AirportActivity.class);
        apt.putExtra(Airports.SITE_NUMBER, siteNumber);
        startActivity(apt);
        finish();
    }
}

From source file:net.naonedbus.fragment.impl.SearchFragment.java

@Override
public void onActivityCreated(final Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    final ActionBar actionBar = ((SherlockFragmentActivity) getActivity()).getSupportActionBar();

    mModalSearchView = (ModalSearchView) actionBar.getCustomView();
    mModalSearchView.setOnQueryTextListener(this);
    mModalSearchView.requestFocus();//from w  ww .j  ava2 s  .c  o m

    final Intent queryIntent = getActivity().getIntent();
    final String queryAction = queryIntent.getAction();
    if (Intent.ACTION_SEARCH.equals(queryAction)) {
        if (queryIntent.getData() == null) {
            // Lancer la recherche
            final String query = queryIntent.getStringExtra(SearchManager.QUERY);
            mModalSearchView.setText(query);
        } else {
            final Integer selectedItemId = Integer.valueOf(queryIntent.getStringExtra(SearchManager.QUERY));
            final int typeId = Integer.valueOf(queryIntent.getStringExtra(SearchManager.EXTRA_DATA_KEY));
            final TypeOverlayItem selectedItemType = TypeOverlayItem.getById(typeId);

            if (selectedItemType.equals(TypeOverlayItem.TYPE_STATION)) {
                // Afficher les parcours de l'arrt slectionn
                final Intent intent = new Intent(getActivity(), ParcoursActivity.class);
                intent.putExtra(ParcoursActivity.PARAM_ID_SATION, selectedItemId);
                startActivity(intent);
            } else {
                // Afficher l'lment sur la carte
                final ParamIntent intent = new ParamIntent(getActivity(), MapActivity.class);
                intent.putExtra(MapFragment.PARAM_ITEM_ID, selectedItemId);
                intent.putExtra(MapFragment.PARAM_ITEM_TYPE, selectedItemType.getId());
                startActivity(intent);
            }
            getActivity().finish();
        }
    }

    mModalSearchView.requestFocus();
}

From source file:com.android.stockbrowser.search.OpenSearchSearchEngine.java

public void startSearch(Context context, String query, Bundle appData, String extraData) {
    String uri = mSearchEngineInfo.getSearchUriForQuery(query);
    if (uri == null) {
        Log.e(TAG, "Unable to get search URI for " + mSearchEngineInfo);
    } else {//from w  ww  .j a  v a  2s  . co m
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
        // Make sure the intent goes to the StockBrowser itself
        intent.setPackage(context.getPackageName());
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        intent.putExtra(SearchManager.QUERY, query);
        if (appData != null) {
            intent.putExtra(SearchManager.APP_DATA, appData);
        }
        if (extraData != null) {
            intent.putExtra(SearchManager.EXTRA_DATA_KEY, extraData);
        }
        intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());
        context.startActivity(intent);
    }
}

From source file:com.android.browser.search.OpenSearchSearchEngine.java

public void startSearch(Context context, String query, Bundle appData, String extraData) {
    String uri = mSearchEngineInfo.getSearchUriForQuery(query);
    if (uri == null) {
        Log.e(TAG, "Unable to get search URI for " + mSearchEngineInfo);
    } else {/*  w w w  . j a  va  2s.c om*/
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
        // Make sure the intent goes to the Browser itself
        intent.setPackage(context.getPackageName());
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        intent.putExtra(SearchManager.QUERY, query);
        if (appData != null) {
            intent.putExtra(SearchManager.APP_DATA, appData);
        }
        if (extraData != null) {
            intent.putExtra(SearchManager.EXTRA_DATA_KEY, extraData);
        }
        intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());
        context.startActivity(intent);
    }
}

From source file:com.miz.mizuu.ShowDetails.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (!MizLib.isPortrait(this))
        if (isFullscreen())
            setTheme(R.style.Theme_Example_Transparent_NoBackGround_FullScreen);
        else// w  w w. java2s .  c  o m
            setTheme(R.style.Theme_Example_Transparent_NoBackGround);
    else if (isFullscreen())
        setTheme(R.style.Theme_Example_Transparent_FullScreen);
    else
        setTheme(R.style.Theme_Example_Transparent);

    getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);

    setContentView(R.layout.viewpager);

    actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    if (spinnerAdapter == null)
        spinnerAdapter = new ActionBarSpinner(this, spinnerItems);

    setTitle(null);

    awesomePager = (ViewPager) findViewById(R.id.awesomepager);
    awesomePager.setOffscreenPageLimit(3); // Required in order to retain all fragments when swiping between them
    awesomePager.setAdapter(new ShowDetailsAdapter(getSupportFragmentManager()));
    awesomePager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
            invalidateOptionsMenu();
        }
    });

    ignorePrefixes = PreferenceManager.getDefaultSharedPreferences(this)
            .getBoolean("prefsIgnorePrefixesInTitles", false);

    // Create and open database
    dbHelper = MizuuApplication.getTvDbAdapter();

    String showId = "";
    // Fetch the database ID of the TV show to view
    if (Intent.ACTION_SEARCH.equals(getIntent().getAction())) {
        showId = getIntent().getStringExtra(SearchManager.EXTRA_DATA_KEY);
    } else {
        showId = getIntent().getStringExtra("showId");
    }

    Cursor cursor = dbHelper.getShow(showId);
    try {
        while (cursor.moveToNext()) {
            thisShow = new TvShow(this, cursor.getString(cursor.getColumnIndex(DbAdapterTvShow.KEY_SHOW_ID)),
                    cursor.getString(cursor.getColumnIndex(DbAdapterTvShow.KEY_SHOW_TITLE)),
                    cursor.getString(cursor.getColumnIndex(DbAdapterTvShow.KEY_SHOW_PLOT)),
                    cursor.getString(cursor.getColumnIndex(DbAdapterTvShow.KEY_SHOW_RATING)),
                    cursor.getString(cursor.getColumnIndex(DbAdapterTvShow.KEY_SHOW_GENRES)),
                    cursor.getString(cursor.getColumnIndex(DbAdapterTvShow.KEY_SHOW_ACTORS)),
                    cursor.getString(cursor.getColumnIndex(DbAdapterTvShow.KEY_SHOW_CERTIFICATION)),
                    cursor.getString(cursor.getColumnIndex(DbAdapterTvShow.KEY_SHOW_FIRST_AIRDATE)),
                    cursor.getString(cursor.getColumnIndex(DbAdapterTvShow.KEY_SHOW_RUNTIME)), ignorePrefixes,
                    cursor.getString(cursor.getColumnIndex(DbAdapterTvShow.KEY_SHOW_EXTRA1)));
        }
    } catch (Exception e) {
        finish();
        return;
    } finally {
        cursor.close();
    }

    if (thisShow == null) {
        finish(); // Finish the activity if the movie doesn't load
        return;
    }

    setupSpinnerItems();

    if (savedInstanceState != null) {
        awesomePager.setCurrentItem(savedInstanceState.getInt("tab", 0));
    }

    // Set the current page item to 1 (episode page) if the TV show start page setting has been changed from TV show details
    if (!PreferenceManager.getDefaultSharedPreferences(this)
            .getString("prefsTvShowsStartPage", getString(R.string.showDetails))
            .equals(getString(R.string.showDetails)))
        awesomePager.setCurrentItem(1);
}

From source file:com.borqs.browser.search.OpenSearchSearchEngine.java

public void startSearch(Context context, String query, Bundle appData, String extraData) {
    Log.i("OpenSearchSearchEng", "startSearch, query: " + query);
    String uri = mSearchEngineInfo.getSearchUriForQuery(query);
    if (uri == null) {
        Log.e(TAG, "Unable to get search URI for " + mSearchEngineInfo);
    } else {/*from  www . j a  v a2s  . c  o  m*/
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
        // Make sure the intent goes to the Browser itself
        intent.setPackage(context.getPackageName());
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        intent.putExtra(SearchManager.QUERY, query);
        if (appData != null) {
            intent.putExtra(SearchManager.APP_DATA, appData);
        }
        if (extraData != null) {
            intent.putExtra(SearchManager.EXTRA_DATA_KEY, extraData);
        }
        intent.putExtra(Browser.EXTRA_APPLICATION_ID, context.getPackageName());
        context.startActivity(intent);
    }
}

From source file:fr.matthiasbosc.translucentmap.MainActivity.java

private void handleIntent(Intent intent) {
    if (intent.getAction().equals(Intent.ACTION_SEARCH)) {
        doSearch(intent.getStringExtra(SearchManager.QUERY));
    } else if (intent.getAction().equals(Intent.ACTION_VIEW)) {
        getPlace(intent.getStringExtra(SearchManager.EXTRA_DATA_KEY));
    }//from   w  w  w  .  ja va2s .  co m
}

From source file:org.transdroid.gui.search.Search.java

private void handleIntent(Intent startIntent) {

    // Get the query string from the intent
    String thequery = getQuery(startIntent);

    // Is this actually a full HTTP URL?
    if (thequery != null && (thequery.startsWith(HttpHelper.SCHEME_HTTP)
            || thequery.startsWith(HttpHelper.SCHEME_MAGNET) || thequery.startsWith(HttpHelper.SCHEME_FILE))) {

        // Redirect this request to the main screen to add the URL directly
        Intent i = new Intent(this, Torrents.class);
        i.setData(Uri.parse(thequery));/*  w w  w.j  av a2  s  . co  m*/
        startActivity(i);
        finish();
        return;

    }

    // Check if Transdroid Torrent Search is installed
    if (!TorrentSearchTask.isTorrentSearchInstalled(this)) {
        showDialog(DIALOG_INSTALLSEARCH);
        empty.setText("");
        return;
    }

    // Load preferences
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    defaultSite = Preferences.readDefaultSearchSiteSettings(prefs);
    allSites = Preferences.readAllSiteSettings(prefs);
    searchSettings = Preferences.readSearchSettings(prefs);

    // Update selection spinner
    disableListNavigation = true;
    getSupportActionBar().setListNavigationCallbacks(buildProvidersAdapter(), onProviderSelected);

    // Switch to a certain site?
    if (startIntent.hasExtra(SearchManager.EXTRA_DATA_KEY)) {
        String switchToKey = startIntent.getStringExtra(SearchManager.EXTRA_DATA_KEY);
        // See if this site (key) exists
        for (SiteSettings site : allSites) {
            if (site.getKey().equals(switchToKey)) {
                // If it is different than the last used (default) site, switch to it
                if (!defaultSite.getKey().equals(switchToKey)) {
                    // Set the default site search to this new site
                    Preferences.storeLastUsedSearchSiteSettings(getApplicationContext(), switchToKey);
                    defaultSite = allSites.get(siteSettingsIndex(site));
                }
                break;
            }
        }

    }

    if (defaultSite == null) {
        return;
    }

    // Start a web search?
    if (defaultSite.isWebSearch()) {

        if (thequery == null || thequery.equals("")) {
            // No search term was provided: show a message and close this search activity
            Toast.makeText(this, R.string.no_query, Toast.LENGTH_LONG).show();
            finish();
            return;
        }

        doWebSearch(defaultSite, thequery);
        finish();
        return;

    }

    // Select the now-selected site in the spinner
    getSupportActionBar().setSelectedNavigationItem(siteSettingsIndex(defaultSite));
    disableListNavigation = false;

    // Normal in-app search
    query = thequery;
    handleQuery();

}