Example usage for android.app SearchManager QUERY

List of usage examples for android.app SearchManager QUERY

Introduction

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

Prototype

String QUERY

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

Click Source Link

Document

Intent extra data key: Use this key with android.content.Intent#getStringExtra content.Intent.getStringExtra() to obtain the query string from Intent.ACTION_SEARCH.

Usage

From source file:org.wheelmap.android.fragment.POIsListWorkerFragment.java

public void executeSearch(Bundle extras) {
    if (!extras.containsKey(SearchManager.QUERY) && !extras.containsKey(SyncService.EXTRA_CATEGORY)
            && !extras.containsKey(SyncService.EXTRA_NODETYPE)
            && !extras.containsKey(SyncService.EXTRA_WHEELCHAIR_STATE))
        return;//  w w  w . j  a v a 2s  .  c o  m

    final Intent intent = new Intent(Intent.ACTION_SYNC, null, getActivity(), SyncService.class);
    intent.putExtras(extras);
    if (!extras.containsKey(SyncService.EXTRA_WHAT)) {
        int what;
        if (extras.containsKey(SyncService.EXTRA_CATEGORY) || extras.containsKey(SyncService.EXTRA_NODETYPE))
            what = SyncService.WHAT_RETRIEVE_NODES;
        else
            what = SyncService.WHAT_SEARCH_NODES;

        intent.putExtra(SyncService.EXTRA_WHAT, what);
    }

    if (extras.containsKey(SyncService.EXTRA_DISTANCE_LIMIT))
        intent.putExtra(SyncService.EXTRA_LOCATION, mLocation);

    intent.putExtra(SyncService.EXTRA_STATUS_RECEIVER, mReceiver);
    getActivity().startService(intent);
}

From source file:com.qubling.sidekick.ui.module.ModuleSearchActivity.java

/** Called when the activity is first created. */
@Override/* w  w w. j a v a2 s  .co m*/
protected void onCreate(Bundle state) {
    super.onCreate(state);

    // Setup the view
    setContentView(R.layout.module_search);

    // Setup BugSense
    Util.setupBugSense(this);

    // Initialize the fragment, if on a tablet
    if (isTwoPanelView()) {
        boolean showingModuleViewer = state != null && state.getBoolean("showingModuleViewer");

        Fragment viewFragment;
        if (showingModuleViewer) {
            viewFragment = new ModuleViewFragment();
        } else {
            viewFragment = new ModuleViewPlaceholderFragment();
        }

        if (state == null)
            getSupportFragmentManager().beginTransaction()
                    .add(R.id.module_view_fragment_container, viewFragment).commit();
    }

    // Check to see if we got a search
    Intent intent = getIntent();
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query = intent.getStringExtra(SearchManager.QUERY);
        getModuleSearchFragment().doNewSearch(query);
    }

    moduleSearchHelper.onCreate(state);

    new ConnectivityCheck(this);

    //        AccountManager am = AccountManager.get(this);
    //        Account[] accounts = am.getAccounts();
    //        for (Account account : accounts) {
    //            Log.d("ModuleSearchActivity", "ACCOUNT " + account.name + ", " + account.type);
    //        }
}

From source file:com.android.calendar.SearchActivity.java

@Override
protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    dynamicTheme.onCreate(this);
    // This needs to be created before setContentView
    mController = CalendarController.getInstance(this);
    mHandler = new Handler();

    mIsMultipane = Utils.getConfigBool(this, R.bool.multiple_pane_config);
    mShowEventDetailsWithAgenda = Utils.getConfigBool(this, R.bool.show_event_details_with_agenda);

    setContentView(R.layout.search);//from www. jav  a  2s. c  o m

    setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);

    mContentResolver = getContentResolver();

    if (mIsMultipane) {
        if (getSupportActionBar() != null) {
            getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP, ActionBar.DISPLAY_HOME_AS_UP);
        }
    } else {
        if (getSupportActionBar() != null) {
            getSupportActionBar().setDisplayOptions(0,
                    ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME);
        }
    }

    // Must be the first to register because this activity can modify the
    // list of event handlers in it's handle method. This affects who the
    // rest of the handlers the controller dispatches to are.
    mController.registerEventHandler(HANDLER_KEY, this);

    mDeleteEventHelper = new DeleteEventHelper(this, this, false /* don't exit when done */);

    long millis = 0;
    if (icicle != null) {
        // Returns 0 if key not found
        millis = icicle.getLong(BUNDLE_KEY_RESTORE_TIME);
        if (DEBUG) {
            Log.v(TAG, "Restore value from icicle: " + millis);
        }
    }
    if (millis == 0) {
        // Didn't find a time in the bundle, look in intent or current time
        millis = Utils.timeFromIntentInMillis(getIntent());
    }

    Intent intent = getIntent();
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query;
        if (icicle != null && icicle.containsKey(BUNDLE_KEY_RESTORE_SEARCH_QUERY)) {
            query = icicle.getString(BUNDLE_KEY_RESTORE_SEARCH_QUERY);
        } else {
            query = intent.getStringExtra(SearchManager.QUERY);
        }
        if ("TARDIS".equalsIgnoreCase(query)) {
            Utils.tardis();
        }
        initFragments(millis, query);
    }
}

From source file:org.melky.geekjuniorapp.GeekJunior.java

private void handleIntent(Intent intent) {
    if (Intent.ACTION_VIEW.equals(intent.getAction())) {
        final FragmentManager fragmentManager = getSupportFragmentManager();
        int i = fragmentManager.getBackStackEntryCount();
        // handles a click on a search suggestion; launches activity to show word
        Uri uri = intent.getData();/* ww  w.  j  a v a2  s .com*/
        Cursor cursor = managedQuery(uri, null, null, null, null);
        cursor.moveToFirst();
        int wIndex = cursor.getColumnIndexOrThrow(GeekDictionaryDatabase.KEY_WORD);
        int dIndex = cursor.getColumnIndexOrThrow(GeekDictionaryDatabase.KEY_DEFINITION);

        //Toast.makeText(this,cursor.getString(wIndex)+"--"+cursor.getString(dIndex),Toast.LENGTH_SHORT).show();
        Toast.makeText(this, R.string.ph_buscar, Toast.LENGTH_SHORT).show();

        searchView.setQuery(cursor.getString(dIndex), true);

        getJsonToFragment(cursor.getString(dIndex), "tag");

        if (i == 0) {
            getSupportFragmentManager().beginTransaction().replace(R.id.container, new PlaceholderFragment(17))
                    .addToBackStack("PlaceholderFragment").commit();
        } else {
            getSupportFragmentManager().beginTransaction().replace(R.id.container, new PlaceholderFragment(17))
                    .addToBackStack("PlaceholderFragment2").commit();
        }

    } else if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        // handles a search query
        String query = intent.getStringExtra(SearchManager.QUERY);
        //do-nothing
    }
}

From source file:com.scooter1556.sms.android.activity.HomeActivity.java

@Override
protected void onMediaControllerConnected() {
    if (voiceSearchParams != null) {
        // If there is a bootstrap parameter to start from a search query, we
        // send it to the media session and set it to null, so it won't play again
        // when the activity is stopped/started or recreated:
        String query = voiceSearchParams.getString(SearchManager.QUERY);
        MediaControllerCompat.getMediaController(this).getTransportControls().playFromSearch(query,
                voiceSearchParams);/*from w w  w  . j  ava 2 s  .c  o  m*/
        voiceSearchParams = null;
    }
}

From source file:com.ronnyml.sweetplayer.ui.MainActivity.java

private void handleIntent(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String search_text = intent.getStringExtra(SearchManager.QUERY);
        if (search_text.equals("") || search_text.length() == 0) {
            Utils.showUserMessage(mActivity.getApplicationContext(), getString(R.string.search_text_empty));
        } else {//from   ww w.  j  a  v  a  2s  . co  m
            Intent newIntent = new Intent(mActivity.getApplicationContext(), MainActivity.class);
            newIntent.putExtra(Constants.IS_SEARCH, true);
            newIntent.putExtra(Constants.SEARCH_TEXT, search_text);
            mActivity.startActivity(newIntent);
        }
        Utils.LogD("Main", search_text);
    }
}

From source file:com.samsunghack.apps.android.noq.NavDrawerMainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // The action bar home/up action should open or close the drawer.
    // ActionBarDrawerToggle will take care of this.
    if (mDrawerToggle.onOptionsItemSelected(item)) {
        return true;
    }/*from  ww  w  .ja  v a 2s .co  m*/
    // Handle action buttons
    switch (item.getItemId()) {
    case R.id.action_websearch:
        // create intent to perform web search for this planet
        Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
        intent.putExtra(SearchManager.QUERY, getActionBar().getTitle());
        // catch event that there's no activity to handle intent
        if (intent.resolveActivity(getPackageManager()) != null) {
            startActivity(intent);
        } else {
            Toast.makeText(this, R.string.app_not_available, Toast.LENGTH_LONG).show();
        }
        return true;

    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.phearom.um.ui.MusicPlayerActivity.java

@Override
protected void onMediaControllerConnected() {
    if (mVoiceSearchParams != null) {
        String query = mVoiceSearchParams.getString(SearchManager.QUERY);
        getSupportMediaController().getTransportControls().playFromSearch(query, mVoiceSearchParams);
        mVoiceSearchParams = null;/*from   w  ww.  java2  s .  c om*/
    }

    getBrowseFragment().onConnected();
}

From source file:com.example.android.navigationdrawerexample.activities.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // The action bar home/up action should open or close the drawer.
    // ActionBarDrawerToggle will take care of this.
    if (drawerToggle.onOptionsItemSelected(item)) {
        return true;
    }//from w  ww  .j ava  2s. c  o  m
    // Handle action buttons
    switch (item.getItemId()) {
    case R.id.action_websearch:
        // create intent to perform web search for this planet
        Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
        intent.putExtra(SearchManager.QUERY, getActionBar().getTitle());
        // catch event that there's no activity to handle intent
        if (intent.resolveActivity(getPackageManager()) != null) {
            startActivity(intent);
        } else {
            Toast.makeText(this, R.string.app_not_available, Toast.LENGTH_LONG).show();
        }
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.jtechme.apphub.FDroid.java

private void handleSearchOrAppViewIntent(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query = intent.getStringExtra(SearchManager.QUERY);
        performSearch(query);/*ww  w  .  jav a2 s  .c  o m*/
        return;
    }

    final Uri data = intent.getData();
    if (data == null) {
        return;
    }

    final String scheme = data.getScheme();
    final String path = data.getPath();
    String packageName = null;
    String query = null;
    if (data.isHierarchical()) {
        final String host = data.getHost();
        if (host == null) {
            return;
        }
        switch (host) {
        case "f-droid.org":
            if (path.startsWith("/repository/browse")) {
                // http://f-droid.org/repository/browse?fdfilter=search+query
                query = UriCompat.getQueryParameter(data, "fdfilter");

                // http://f-droid.org/repository/browse?fdid=packageName
                packageName = UriCompat.getQueryParameter(data, "fdid");
            } else if (path.startsWith("/app")) {
                // http://f-droid.org/app/packageName
                packageName = data.getLastPathSegment();
                if ("app".equals(packageName)) {
                    packageName = null;
                }
            }
            break;
        case "details":
            // market://details?id=app.id
            packageName = UriCompat.getQueryParameter(data, "id");
            break;
        case "search":
            // market://search?q=query
            query = UriCompat.getQueryParameter(data, "q");
            break;
        case "play.google.com":
            if (path.startsWith("/store/apps/details")) {
                // http://play.google.com/store/apps/details?id=app.id
                packageName = UriCompat.getQueryParameter(data, "id");
            } else if (path.startsWith("/store/search")) {
                // http://play.google.com/store/search?q=foo
                query = UriCompat.getQueryParameter(data, "q");
            }
            break;
        case "apps":
        case "amazon.com":
        case "www.amazon.com":
            // amzn://apps/android?p=app.id
            // http://amazon.com/gp/mas/dl/android?s=app.id
            packageName = UriCompat.getQueryParameter(data, "p");
            query = UriCompat.getQueryParameter(data, "s");
            break;
        }
    } else if ("fdroid.app".equals(scheme)) {
        // fdroid.app:app.id
        packageName = data.getSchemeSpecificPart();
    } else if ("fdroid.search".equals(scheme)) {
        // fdroid.search:query
        query = data.getSchemeSpecificPart();
    }

    if (!TextUtils.isEmpty(query)) {
        // an old format for querying via packageName
        if (query.startsWith("pname:"))
            packageName = query.split(":")[1];

        // sometimes, search URLs include pub: or other things before the query string
        if (query.contains(":"))
            query = query.split(":")[1];
    }

    if (!TextUtils.isEmpty(packageName)) {
        Utils.debugLog(TAG, "FDroid launched via app link for '" + packageName + "'");
        Intent intentToInvoke = new Intent(this, AppDetails.class);
        intentToInvoke.putExtra(AppDetails.EXTRA_APPID, packageName);
        startActivity(intentToInvoke);
    } else if (!TextUtils.isEmpty(query)) {
        Utils.debugLog(TAG, "FDroid launched via search link for '" + query + "'");
        performSearch(query);
    }
}