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:Main.java

public static void searchWeb(Context context, String word) {
    Intent i = new Intent(Intent.ACTION_WEB_SEARCH);
    i.putExtra(SearchManager.QUERY, word);
    context.startActivity(i);/*from  w  ww. j  a  va 2  s. co m*/
}

From source file:Main.java

public static void searchContent(Context context, String content) {
    Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
    intent.putExtra(SearchManager.QUERY, content);
    context.startActivity(intent);/*  w w  w .  j  a  v a 2s .  co m*/
}

From source file:Main.java

public static void showGoogleSearchIntent(Context context, String query) {
    Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
    intent.putExtra(SearchManager.QUERY, query); // query contains search string
    context.startActivity(intent);/*from  w  w w  . ja  v a 2 s . co m*/
}

From source file:Main.java

@NonNull
public static Intent search(@NonNull String query) {
    final Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
    intent.putExtra(SearchManager.QUERY, query);
    return intent;
}

From source file:Main.java

public static Intent webSearch(String query) {
    final Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
    intent.putExtra(SearchManager.QUERY, query);
    return intent;
}

From source file:Main.java

/**
 * When doing a web search, there are two situations.
 *
 * If user type in a url or something similar to a url, we need to
 * open the url directly for user. Otherwise, we just search the
 * content user type in with default search engine.
 *
 * @param str content user want to search or url user want to visit
 * @return intent/*w w  w.j  ava  2s  . c  om*/
 */
public static Intent getWebSearchIntent(String str) {
    Intent intent;
    // if search content contain ".", we think it's a url
    if (str.contains(".")) {
        if (!str.startsWith("http://") && !str.startsWith("https://"))
            str = "http://" + str;
        intent = new Intent(Intent.ACTION_VIEW, Uri.parse(str));
    } else {
        intent = new Intent(Intent.ACTION_WEB_SEARCH);
        intent.putExtra(SearchManager.QUERY, str);
    }
    return intent;
}

From source file:com.android.common.util.IntentUtils.java

/**
 * Search a word in a browser/* w w  w. ja  va2s . c om*/
 *
 * @param context
 * @param string
 */
public static void search(Context context, String string) {
    Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
    intent.putExtra(SearchManager.QUERY, string);
    context.startActivity(intent);
}

From source file:SearchResultActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_search_result);
    mTextViewSearchResult = (TextView) findViewById(R.id.textViewSearchResult);

    if (Intent.ACTION_SEARCH.equals(getIntent().getAction())) {
        handleSearch(getIntent().getStringExtra(SearchManager.QUERY));
    }/*from   www  .  j a  va2  s. com*/
}

From source file:SearchResultActivity.java

@Override
protected void onNewIntent(Intent intent) {
    super.onNewIntent(intent);
    if (Intent.ACTION_SEARCH.equals(getIntent().getAction())) {
        handleSearch(intent.getStringExtra(SearchManager.QUERY));
    }//  w ww .ja  v a 2s .co m
}

From source file:org.klnusbaum.udj.ArtistSearchFragment.java

public Loader<MusicSearchLoader.MusicSearchResult> getLoader(Account account) {
    String artistQuery = getActivity().getIntent().getStringExtra(SearchManager.QUERY);
    return new ArtistSearchLoader(getActivity(), artistQuery, account);
}