Search in sources :

Example 6 with CanceledException

use of android.app.PendingIntent.CanceledException in project K6nele by Kaljurand.

the class HttpRecognitionService method returnOrForwardMatches.

/**
     * Returns the transcription results to the caller,
     * or sends them to the pending intent.
     *
     * @param everything recognition results (all the components)
     * @param counts     number of linearizations for each hyphothesis (needed to interpret {@code everything})
     * @param matches    recognition results (just linearizations)
     */
private void returnOrForwardMatches(ArrayList<String> everything, ArrayList<Integer> counts, ArrayList<String> matches) {
    PendingIntent pendingIntent = IntentUtils.getPendingIntent(getExtras());
    if (pendingIntent == null) {
        Bundle bundle = new Bundle();
        // TODO: results_recognition
        bundle.putStringArrayList(SpeechRecognizer.RESULTS_RECOGNITION, matches);
        bundle.putStringArrayList(Extras.RESULTS_RECOGNITION_LINEARIZATIONS, everything);
        bundle.putIntegerArrayList(Extras.RESULTS_RECOGNITION_LINEARIZATION_COUNTS, counts);
        Log.i("Callback: results: RESULTS_RECOGNITION: " + matches);
        Log.i("Callback: results: RESULTS_RECOGNITION_LINEARIZATIONS: " + everything);
        Log.i("Callback: results: RESULTS_RECOGNITION_LINEARIZATIONS_COUNTS: " + counts);
        onResults(bundle);
    } else {
        Log.i("EXTRA_RESULTS_PENDINGINTENT_BUNDLE was used with SpeechRecognizer (this is not tested)");
        // This probably never occurs...
        Bundle bundle = getExtras().getBundle(RecognizerIntent.EXTRA_RESULTS_PENDINGINTENT_BUNDLE);
        if (bundle == null) {
            bundle = new Bundle();
        }
        String match = matches.get(0);
        //mExtraResultsPendingIntentBundle.putString(SearchManager.QUERY, match);
        Intent intent = new Intent();
        intent.putExtras(bundle);
        // This is for Google Maps, YouTube, ...
        intent.putExtra(SearchManager.QUERY, match);
        // This is for SwiftKey X, ...
        // TODO: android.speech.extra.RESULTS
        intent.putStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS, matches);
        intent.putStringArrayListExtra(Extras.RESULTS_RECOGNITION_LINEARIZATIONS, everything);
        intent.putIntegerArrayListExtra(Extras.RESULTS_RECOGNITION_LINEARIZATION_COUNTS, counts);
        try {
            // TODO: dummy number 1234
            pendingIntent.send(this, 1234, intent);
        } catch (CanceledException e) {
        // TODO
        }
    }
}
Also used : CanceledException(android.app.PendingIntent.CanceledException) Bundle(android.os.Bundle) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) RecognizerIntent(android.speech.RecognizerIntent) PendingIntent(android.app.PendingIntent)

Example 7 with CanceledException

use of android.app.PendingIntent.CanceledException in project android_frameworks_base by ResurrectionRemix.

the class ImeTile method handleClick.

@Override
public void handleClick() {
    mHost.collapsePanels();
    Intent intent = new Intent(Settings.ACTION_SHOW_INPUT_METHOD_PICKER);
    PendingIntent pendingIntent = PendingIntent.getBroadcast(mContext, 0, intent, 0);
    try {
        pendingIntent.send();
    } catch (CanceledException e) {
    }
}
Also used : CanceledException(android.app.PendingIntent.CanceledException) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent)

Example 8 with CanceledException

use of android.app.PendingIntent.CanceledException in project AndroidChromium by JackyAndroid.

the class CustomTabBottomBarDelegate method sendPendingIntentWithUrl.

private static void sendPendingIntentWithUrl(PendingIntent pendingIntent, Intent extraIntent, ChromeActivity activity) {
    Intent addedIntent = extraIntent == null ? new Intent() : new Intent(extraIntent);
    Tab tab = activity.getActivityTab();
    if (tab != null)
        addedIntent.setData(Uri.parse(tab.getUrl()));
    try {
        pendingIntent.send(activity, 0, addedIntent, null, null);
    } catch (CanceledException e) {
        Log.e(TAG, "CanceledException when sending pending intent.");
    }
}
Also used : CanceledException(android.app.PendingIntent.CanceledException) Tab(org.chromium.chrome.browser.tab.Tab) CustomTabsIntent(android.support.customtabs.CustomTabsIntent) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent)

Example 9 with CanceledException

use of android.app.PendingIntent.CanceledException in project AndroidChromium by JackyAndroid.

the class CustomTabIntentDataProvider method clickMenuItemWithUrl.

/**
     * Triggers the client-defined action when the user clicks a custom menu item.
     * @param menuIndex The index that the menu item is shown in the result of
     *                  {@link #getMenuTitles()}
     */
public void clickMenuItemWithUrl(ChromeActivity activity, int menuIndex, String url) {
    Intent addedIntent = new Intent();
    addedIntent.setData(Uri.parse(url));
    try {
        // Media viewers pass in PendingIntents that contain CHOOSER Intents.  Setting the data
        // in these cases prevents the Intent from firing correctly.
        PendingIntent pendingIntent = mMenuEntries.get(menuIndex).second;
        pendingIntent.send(activity, 0, isMediaViewer() ? null : addedIntent, mOnFinished, null);
    } catch (CanceledException e) {
        Log.e(TAG, "Custom tab in Chrome failed to send pending intent.");
    }
}
Also used : CanceledException(android.app.PendingIntent.CanceledException) CustomTabsIntent(android.support.customtabs.CustomTabsIntent) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent)

Example 10 with CanceledException

use of android.app.PendingIntent.CanceledException in project AndroidChromium by JackyAndroid.

the class CustomTabIntentDataProvider method sendButtonPendingIntentWithUrl.

/**
     * Sends the pending intent for the custom button on toolbar with the given url as data.
     * @param context The context to use for sending the {@link PendingIntent}.
     * @param url The url to attach as additional data to the {@link PendingIntent}.
     */
public void sendButtonPendingIntentWithUrl(Context context, String url) {
    Intent addedIntent = new Intent();
    addedIntent.setData(Uri.parse(url));
    try {
        getCustomButtonOnToolbar().getPendingIntent().send(context, 0, addedIntent, mOnFinished, null);
    } catch (CanceledException e) {
        Log.e(TAG, "CanceledException while sending pending intent in custom tab");
    }
}
Also used : CanceledException(android.app.PendingIntent.CanceledException) CustomTabsIntent(android.support.customtabs.CustomTabsIntent) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent)

Aggregations

CanceledException (android.app.PendingIntent.CanceledException)19 PendingIntent (android.app.PendingIntent)16 Intent (android.content.Intent)16 AlertDialog (android.app.AlertDialog)3 CustomTabsIntent (android.support.customtabs.CustomTabsIntent)3 KeyEvent (android.view.KeyEvent)3 Bundle (android.os.Bundle)2 RecognizerIntent (android.speech.RecognizerIntent)2 SmsMessage (android.telephony.SmsMessage)2 Activity (android.app.Activity)1 DialogInterface (android.content.DialogInterface)1 OnClickListener (android.content.DialogInterface.OnClickListener)1 SharedPreferences (android.content.SharedPreferences)1 Resources (android.content.res.Resources)1 LocationListener (android.location.LocationListener)1 AsyncResult (android.os.AsyncResult)1 Message (android.os.Message)1 OSUtils.getResourceString (com.onesignal.OSUtils.getResourceString)1 ArrayList (java.util.ArrayList)1 Tab (org.chromium.chrome.browser.tab.Tab)1