Java Code Examples for android.content.Intent#ACTION_WEB_SEARCH

The following examples show how to use android.content.Intent#ACTION_WEB_SEARCH . These examples are extracted from open source projects. 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 Project: ui   File: MainActivity.java    License: 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 2
Source Project: android_9.0.0_r45   File: Searchables.java    License: 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 3
@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 4
Source Project: delion   File: ChromeActivity.java    License: 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 Project: AndroidChromium   File: ChromeActivity.java    License: 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 6
Source Project: 365browser   File: ChromeActivity.java    License: 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 7
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
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
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 Project: android-apps   File: ResultHandler.java    License: 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 11
Source Project: PHONK   File: Intents.java    License: 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
final void webSearch(String query) {
  Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
  intent.putExtra("query", query);
  launchIntent(intent);
}
 
Example 13
final void webSearch(String query) {
  Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
  intent.putExtra("query", query);
  launchIntent(intent);
}
 
Example 14
Source Project: delion   File: ChromeLauncherActivity.java    License: 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
final void webSearch(String query) {
  Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
  intent.putExtra("query", query);
  launchIntent(intent);
}
 
Example 16
@Override
public void processWebSearchIntent(String query) {
    Intent searchIntent = new Intent(Intent.ACTION_WEB_SEARCH);
    searchIntent.putExtra(SearchManager.QUERY, query);
    startActivity(searchIntent);
}
 
Example 17
@Override
public void processWebSearchIntent(String query) {
    Intent searchIntent = new Intent(Intent.ACTION_WEB_SEARCH);
    searchIntent.putExtra(SearchManager.QUERY, query);
    startActivity(searchIntent);
}
 
Example 18
final void webSearch(String query) {
  Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
  intent.putExtra("query", query);
  launchIntent(intent);
}
 
Example 19
Source Project: barcodescanner-lib-aar   File: ResultHandler.java    License: 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 Project: reacteu-app   File: ResultHandler.java    License: 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);
}