Java Code Examples for org.chromium.chrome.browser.util.IntentUtils#safeGetStringArrayListExtra()

The following examples show how to use org.chromium.chrome.browser.util.IntentUtils#safeGetStringArrayListExtra() . 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: IntentHandler.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Records an action when a user chose to handle a URL in Chrome that could have been handled
 * by an application installed on the phone. Also records the name of that application.
 * This doesn't include generic URL handlers, such as browsers.
 */
private void recordAppHandlersForIntent(Intent intent) {
    List<String> packages = IntentUtils.safeGetStringArrayListExtra(intent,
            IntentHandler.EXTRA_EXTERNAL_NAV_PACKAGES);
    if (packages != null && packages.size() > 0) {
        RecordUserAction.record("MobileExternalNavigationReceived");
        for (String name : packages) {
            RapporServiceBridge.sampleString("Android.ExternalNavigationNotChosen", name);
        }
    }
}
 
Example 2
Source File: IntentHandler.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * Extracts the URL from voice search result intent.
 * @return URL if it was found, null otherwise.
 */
static String getUrlFromVoiceSearchResult(Intent intent) {
    if (!RecognizerResultsIntent.ACTION_VOICE_SEARCH_RESULTS.equals(intent.getAction())) {
        return null;
    }
    ArrayList<String> results = IntentUtils.safeGetStringArrayListExtra(
            intent, RecognizerResultsIntent.EXTRA_VOICE_SEARCH_RESULT_STRINGS);

    // Allow specifying a single voice result via the command line during testing (as the
    // 'am' command does not allow specifying an array of strings).
    if (results == null && sTestIntentsEnabled) {
        String testResult = IntentUtils.safeGetStringExtra(
                intent, RecognizerResultsIntent.EXTRA_VOICE_SEARCH_RESULT_STRINGS);
        if (testResult != null) {
            results = new ArrayList<String>();
            results.add(testResult);
        }
    }
    if (results == null || results.size() == 0) return null;
    String query = results.get(0);
    String url = AutocompleteController.nativeQualifyPartialURLQuery(query);
    if (url == null) {
        List<String> urls = IntentUtils.safeGetStringArrayListExtra(
                intent, RecognizerResultsIntent.EXTRA_VOICE_SEARCH_RESULT_URLS);
        if (urls != null && urls.size() > 0) {
            url = urls.get(0);
        } else {
            url = TemplateUrlService.getInstance().getUrlForVoiceSearchQuery(query);
        }
    }
    return url;
}
 
Example 3
Source File: IntentHandler.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Records an action when a user chose to handle a URL in Chrome that could have been handled
 * by an application installed on the phone. Also records the name of that application.
 * This doesn't include generic URL handlers, such as browsers.
 */
private void recordAppHandlersForIntent(Intent intent) {
    List<String> packages = IntentUtils.safeGetStringArrayListExtra(intent,
            IntentHandler.EXTRA_EXTERNAL_NAV_PACKAGES);
    if (packages != null && packages.size() > 0) {
        RecordUserAction.record("MobileExternalNavigationReceived");
        for (String name : packages) {
            RapporServiceBridge.sampleString("Android.ExternalNavigationNotChosen", name);
        }
    }
}
 
Example 4
Source File: IntentHandler.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Extracts the URL from voice search result intent.
 * @return URL if it was found, null otherwise.
 */
static String getUrlFromVoiceSearchResult(Intent intent) {
    if (!RecognizerResultsIntent.ACTION_VOICE_SEARCH_RESULTS.equals(intent.getAction())) {
        return null;
    }
    ArrayList<String> results = IntentUtils.safeGetStringArrayListExtra(
            intent, RecognizerResultsIntent.EXTRA_VOICE_SEARCH_RESULT_STRINGS);

    // Allow specifying a single voice result via the command line during testing (as the
    // 'am' command does not allow specifying an array of strings).
    if (results == null && sTestIntentsEnabled) {
        String testResult = IntentUtils.safeGetStringExtra(
                intent, RecognizerResultsIntent.EXTRA_VOICE_SEARCH_RESULT_STRINGS);
        if (testResult != null) {
            results = new ArrayList<String>();
            results.add(testResult);
        }
    }
    if (results == null || results.size() == 0) return null;
    String query = results.get(0);
    String url = AutocompleteController.nativeQualifyPartialURLQuery(query);
    if (url == null) {
        List<String> urls = IntentUtils.safeGetStringArrayListExtra(
                intent, RecognizerResultsIntent.EXTRA_VOICE_SEARCH_RESULT_URLS);
        if (urls != null && urls.size() > 0) {
            url = urls.get(0);
        } else {
            url = TemplateUrlService.getInstance().getUrlForVoiceSearchQuery(query);
        }
    }
    return url;
}
 
Example 5
Source File: IntentHandler.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Records an action when a user chose to handle a URL in Chrome that could have been handled
 * by an application installed on the phone. Also records the name of that application.
 * This doesn't include generic URL handlers, such as browsers.
 */
private void recordAppHandlersForIntent(Intent intent) {
    List<String> packages = IntentUtils.safeGetStringArrayListExtra(intent,
            IntentHandler.EXTRA_EXTERNAL_NAV_PACKAGES);
    if (packages != null && packages.size() > 0) {
        RecordUserAction.record("MobileExternalNavigationReceived");
        for (String name : packages) {
            RapporServiceBridge.sampleString("Android.ExternalNavigationNotChosen", name);
        }
    }
}
 
Example 6
Source File: IntentHandler.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Extracts the URL from voice search result intent.
 * @return URL if it was found, null otherwise.
 */
static String getUrlFromVoiceSearchResult(Intent intent) {
    if (!RecognizerResultsIntent.ACTION_VOICE_SEARCH_RESULTS.equals(intent.getAction())) {
        return null;
    }
    ArrayList<String> results = IntentUtils.safeGetStringArrayListExtra(
            intent, RecognizerResultsIntent.EXTRA_VOICE_SEARCH_RESULT_STRINGS);

    // Allow specifying a single voice result via the command line during testing (as the
    // 'am' command does not allow specifying an array of strings).
    if (results == null && sTestIntentsEnabled) {
        String testResult = IntentUtils.safeGetStringExtra(
                intent, RecognizerResultsIntent.EXTRA_VOICE_SEARCH_RESULT_STRINGS);
        if (testResult != null) {
            results = new ArrayList<String>();
            results.add(testResult);
        }
    }
    if (results == null || results.size() == 0) return null;
    String query = results.get(0);
    String url = AutocompleteController.nativeQualifyPartialURLQuery(query);
    if (url == null) {
        List<String> urls = IntentUtils.safeGetStringArrayListExtra(
                intent, RecognizerResultsIntent.EXTRA_VOICE_SEARCH_RESULT_URLS);
        if (urls != null && urls.size() > 0) {
            url = urls.get(0);
        } else {
            url = TemplateUrlService.getInstance().getUrlForVoiceSearchQuery(query);
        }
    }
    return url;
}