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
}
}
}
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) {
}
}
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.");
}
}
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.");
}
}
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");
}
}
Aggregations