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:com.example.android.navigationdrawerexample.BottomDrawerActivity.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 (mVerticalDrawerToggle.onOptionsItemSelected(item)) {
        return true;
    }// ww w  . j av  a 2 s  .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, getSupportActionBar().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:net.zionsoft.obadiah.ui.activities.SearchActivity.java

private void handleStartIntent(Intent intent) {
    final String action = intent.getAction();
    if (searchView != null
            && (SearchIntents.ACTION_SEARCH.equals(action) || Intent.ACTION_SEARCH.equals(action))) {
        final String query = intent.getStringExtra(SearchManager.QUERY);
        if (!TextUtils.isEmpty(query)) {
            searchView.setQuery(query, true);
        }//from  w w  w  .  j  av  a2 s.com
    }
}

From source file:com.zns.comicdroid.activity.Start.java

@Override
protected void onNewIntent(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query = intent.getStringExtra(SearchManager.QUERY);
        BaseListFragment fragment = getCurrentFragment();
        if (fragment != null) {
            fragment.setFilter(query);/*from w  w  w.ja va 2  s .  c  o m*/
        }
    }
}

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

protected void initializeFromParams(Bundle savedInstanceState, Intent intent) {
    String mediaId = null;/*from   w  ww  . j  av  a  2  s  .c o m*/
    if (intent.getAction() != null
            && intent.getAction().equals(MediaStore.INTENT_ACTION_MEDIA_PLAY_FROM_SEARCH)) {
        mVoiceSearchParams = intent.getExtras();
        LogHelper.d(TAG, "Starting from voice search query=",
                mVoiceSearchParams.getString(SearchManager.QUERY));
    } else {
        if (savedInstanceState != null) {
            mediaId = savedInstanceState.getString(SAVED_MEDIA_ID);
        }
    }
    navigateToBrowser(mediaId);
}

From source file:de.tap.easy_xkcd.Activities.SearchResultsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    prefHelper = new PrefHelper(getApplicationContext());
    setTheme(prefHelper.getTheme());//from w  w w  . ja  v  a 2 s .c  o  m
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_search_results);
    ButterKnife.bind(this);

    //Setup toolbar and status bar color
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    assert getSupportActionBar() != null;
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    TypedValue typedValue = new TypedValue();
    getTheme().resolveAttribute(R.attr.colorPrimaryDark, typedValue, true);
    TypedValue typedValue2 = new TypedValue();
    getTheme().resolveAttribute(R.attr.colorPrimary, typedValue2, true);
    toolbar.setBackgroundColor(typedValue2.data);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        getWindow().setStatusBarColor(typedValue.data);
        if (!prefHelper.colorNavbar())
            getWindow().setNavigationBarColor(ContextCompat.getColor(this, R.color.ColorPrimaryBlack));
    }

    LinearLayoutManager llm = new LinearLayoutManager(this);
    rv.setLayoutManager(llm);
    rv.setHasFixedSize(true);

    Intent intent = getIntent();
    if (savedInstanceState == null) {
        query = intent.getStringExtra(SearchManager.QUERY);
    } else {
        query = savedInstanceState.getString("query");
    }
    getSupportActionBar()
            .setTitle(getResources().getString(R.string.title_activity_search_results) + " " + query);
    mProgress = ProgressDialog.show(this, "", getResources().getString(R.string.loading_results), true);

    if (savedInstanceState == null) {
        new updateDatabase().execute();
    } else {
        new searchTask().execute(query);
    }
}

From source file:net.vivekiyer.GAL.CorporateAddressBook.java

@Override
protected void onNewIntent(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction()))
        intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
    super.onNewIntent(intent);
    setIntent(intent);/*from w ww . j  a  va2s .  com*/
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        final String query = intent.getStringExtra(SearchManager.QUERY);
        performSearch(query);
    }
}

From source file:de.janrenz.app.mediathek.SearchActivity.java

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

From source file:com.battlelancer.seriesguide.ui.SearchActivity.java

private void submitSearchQuery(String query) {
    Bundle args = new Bundle();
    args.putString(SearchManager.QUERY, query);

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        Bundle appData = extras.getBundle(SearchManager.APP_DATA);
        if (appData != null) {
            args.putBundle(SearchManager.APP_DATA, appData);
        }/*from   w ww.j  av a 2 s  .  c  om*/
    }

    submitSearchQuery(args);
}

From source file:com.songnick.blogdemo.NetEaseDemo_Activity.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;
    }// w  w  w. j ava  2  s .  com
    // Handle action buttons
    switch (item.getItemId()) {
    case R.id.action_settings:
        // 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:org.fs.galleon.presenters.MainActivityPresenter.java

@Override
public void handleSearch(Intent intent) {
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query = intent.getStringExtra(SearchManager.QUERY);
        Observable.just(query).flatMap(txt -> {
            SearchQueryValidator q = SearchQueryValidator.newInstance();
            ValidationResult<String> valid = q.validate(txt, Locale.getDefault());
            return Observable.just(valid);
        }).filter(ValidationResult::isValid).subscribe(isValid -> {
            if (!view.isProgressVisible()) {
                view.showProgress();//from w ww.j a v a  2  s .  c om
            }
            //creates if not previously initialized if there is any we need previous subscription to be canceled accordingly
            createIfUsecaseNotExists(isValid.value());
            usecase.executeAsyncWidthDelay(new ISearchCustomersUseCase.Callback() {
                @Override
                public void onSuccess(Response<List<Customer>> response) {
                    if (response.isSuccess()) {
                        //we send it to our customer
                        BusManager.send(new SearchFoundEvent(response.data()));
                    } else {
                        //show error
                        log(Log.WARN, String.format(Locale.ENGLISH, "ErrorCode: %d\nErrorMessage: %s\n",
                                response.code(), response.message()));
                        view.showError(String.format(Locale.ENGLISH, "Error occured while executing.. '%s'",
                                response.message()));
                    }
                }

                @Override
                public void onError(Throwable thr) {
                    log(thr);
                }

                @Override
                public void onCompleted() {
                    view.hideProgress();
                }
            }, QUERY_DELAY, TimeUnit.MILLISECONDS);
        });
    }
}