Java Code Examples for android.content.Intent#ACTION_WEB_SEARCH

The following examples show how to use android.content.Intent#ACTION_WEB_SEARCH . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Searchables.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * Finds the web search activity.
 *
 * Only looks in the package of the global search activity.
 */
private ComponentName findWebSearchActivity(ComponentName globalSearchActivity) {
    if (globalSearchActivity == null) {
        return null;
    }
    Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
    intent.setPackage(globalSearchActivity.getPackageName());
    List<ResolveInfo> activities =
            queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);

    if (activities != null && !activities.isEmpty()) {
        ActivityInfo ai = activities.get(0).activityInfo;
        // TODO: do some sanity checks here?
        return new ComponentName(ai.packageName, ai.name);
    }
    Log.w(LOG_TAG, "No web search activity found");
    return null;
}
 
Example 2
Source File: ChromeActivity.java    From 365browser with Apache License 2.0 6 votes vote down vote up
protected IntentHandlerDelegate createIntentHandlerDelegate() {
    return new IntentHandlerDelegate() {
        @Override
        public void processWebSearchIntent(String query) {
            Intent searchIntent = new Intent(Intent.ACTION_WEB_SEARCH);
            searchIntent.putExtra(SearchManager.QUERY, query);
            startActivity(searchIntent);
        }

        @Override
        public void processUrlViewIntent(String url, String referer, String headers,
                TabOpenType tabOpenType, String externalAppId, int tabIdToBringToFront,
                boolean hasUserGesture, Intent intent) {
        }
    };
}
 
Example 3
Source File: ChromeActivity.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
protected IntentHandlerDelegate createIntentHandlerDelegate() {
    return new IntentHandlerDelegate() {
        @Override
        public void processWebSearchIntent(String query) {
            Intent searchIntent = new Intent(Intent.ACTION_WEB_SEARCH);
            searchIntent.putExtra(SearchManager.QUERY, query);
            startActivity(searchIntent);
        }

        @Override
        public void processUrlViewIntent(String url, String referer, String headers,
                TabOpenType tabOpenType, String externalAppId, int tabIdToBringToFront,
                boolean hasUserGesture, Intent intent) {
        }
    };
}
 
Example 4
Source File: ChromeActivity.java    From delion with Apache License 2.0 6 votes vote down vote up
protected IntentHandlerDelegate createIntentHandlerDelegate() {
    return new IntentHandlerDelegate() {
        @Override
        public void processWebSearchIntent(String query) {
            Intent searchIntent = new Intent(Intent.ACTION_WEB_SEARCH);
            searchIntent.putExtra(SearchManager.QUERY, query);
            startActivity(searchIntent);
        }

        @Override
        public void processUrlViewIntent(String url, String referer, String headers,
                TabOpenType tabOpenType, String externalAppId, int tabIdToBringToFront,
                boolean hasUserGesture, Intent intent) {
        }
    };
}
 
Example 5
Source File: NavigationDrawerActivity.java    From android-NavigationDrawer with Apache License 2.0 6 votes vote down vote up
@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;
    }
    // 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);
    }
}
 
Example 6
Source File: MainActivity.java    From ui with Apache License 2.0 6 votes vote down vote up
@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;
    }
    // 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);
    }
}
 
Example 7
Source File: AbsTagEditorActivity.java    From RetroMusicPlayer with GNU General Public License v3.0 5 votes vote down vote up
protected void searchWebFor(String... keys) {
    StringBuilder stringBuilder = new StringBuilder();
    for (String key : keys) {
        stringBuilder.append(key);
        stringBuilder.append(" ");
    }
    Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
    intent.putExtra(SearchManager.QUERY, stringBuilder.toString());
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    startActivity(intent);
}
 
Example 8
Source File: AbsTagEditorActivity.java    From Music-Player with GNU General Public License v3.0 5 votes vote down vote up
protected void searchWebFor(String... keys) {
    StringBuilder stringBuilder = new StringBuilder();
    for (String key : keys) {
        stringBuilder.append(key);
        stringBuilder.append(" ");
    }
    Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
    intent.putExtra(SearchManager.QUERY, stringBuilder.toString());
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    startActivity(intent);
}
 
Example 9
Source File: SearchOnGoogleDialogFragment.java    From SmileEssence with MIT License 5 votes vote down vote up
private void execute() {
    hideIME();
    Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
    intent.putExtra(SearchManager.QUERY, editText.getText().toString());
    getActivity().startActivity(intent);
    DialogHelper.closeAll(getActivity());
}
 
Example 10
Source File: ResultHandler.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
final void webSearch(String query) {
  Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
  intent.putExtra("query", query);
  launchIntent(intent);
}
 
Example 11
Source File: Intents.java    From PHONK with GNU General Public License v3.0 4 votes vote down vote up
public static void webSearch(Context c, String text) {
    Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
    intent.setData(Uri.parse(text));
    c.startActivity(intent);
}
 
Example 12
Source File: ResultHandler.java    From ZXing-Standalone-library with Apache License 2.0 4 votes vote down vote up
final void webSearch(String query) {
  Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
  intent.putExtra("query", query);
  launchIntent(intent);
}
 
Example 13
Source File: ResultHandler.java    From android-apps with MIT License 4 votes vote down vote up
final void webSearch(String query) {
  Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
  intent.putExtra("query", query);
  launchIntent(intent);
}
 
Example 14
Source File: ChromeLauncherActivity.java    From delion with Apache License 2.0 4 votes vote down vote up
@Override
public void processWebSearchIntent(String query) {
    Intent searchIntent = new Intent(Intent.ACTION_WEB_SEARCH);
    searchIntent.putExtra(SearchManager.QUERY, query);
    startActivity(searchIntent);
}
 
Example 15
Source File: ResultHandler.java    From analyzer-of-android-for-Apache-Weex with Apache License 2.0 4 votes vote down vote up
final void webSearch(String query) {
  Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
  intent.putExtra("query", query);
  launchIntent(intent);
}
 
Example 16
Source File: ChromeLauncherActivity.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@Override
public void processWebSearchIntent(String query) {
    Intent searchIntent = new Intent(Intent.ACTION_WEB_SEARCH);
    searchIntent.putExtra(SearchManager.QUERY, query);
    startActivity(searchIntent);
}
 
Example 17
Source File: ChromeLauncherActivity.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
public void processWebSearchIntent(String query) {
    Intent searchIntent = new Intent(Intent.ACTION_WEB_SEARCH);
    searchIntent.putExtra(SearchManager.QUERY, query);
    startActivity(searchIntent);
}
 
Example 18
Source File: ResultHandler.java    From Study_Android_Demo with Apache License 2.0 4 votes vote down vote up
final void webSearch(String query) {
  Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
  intent.putExtra("query", query);
  launchIntent(intent);
}
 
Example 19
Source File: ResultHandler.java    From barcodescanner-lib-aar with MIT License 4 votes vote down vote up
final void webSearch(String query) {
  Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
  intent.putExtra("query", query);
  launchIntent(intent);
}
 
Example 20
Source File: ResultHandler.java    From reacteu-app with MIT License 4 votes vote down vote up
final void webSearch(String query) {
  Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
  intent.putExtra("query", query);
  launchIntent(intent);
}