Java Code Examples for android.app.RemoteInput#getResultsFromIntent()
The following examples show how to use
android.app.RemoteInput#getResultsFromIntent() .
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: NotificationPlatformBridge.java From 365browser with Apache License 2.0 | 6 votes |
@Nullable static String getNotificationReply(Intent intent) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) { // RemoteInput was added in KITKAT_WATCH. if (intent.getStringExtra(NotificationConstants.EXTRA_NOTIFICATION_REPLY) != null) { // If the notification click went through the job scheduler, we will have set // the reply as a standard string extra. return intent.getStringExtra(NotificationConstants.EXTRA_NOTIFICATION_REPLY); } Bundle remoteInputResults = RemoteInput.getResultsFromIntent(intent); if (remoteInputResults != null) { CharSequence reply = remoteInputResults.getCharSequence(NotificationConstants.KEY_TEXT_REPLY); if (reply != null) { return reply.toString(); } } } return null; }
Example 2
Source File: KeyboardInputController.java From wearmouse with Apache License 2.0 | 5 votes |
/** * Should be called in the Activity's (or Fragment's) onActivityResult() method that was invoked * in response to the Intent returned by {@code getInputIntent}. */ public void onActivityResult(Intent data) { final Bundle result = RemoteInput.getResultsFromIntent(data); if (result != null) { CharSequence text = result.getCharSequence(Intent.EXTRA_TEXT); if (text != null) { for (int i = 0, n = text.length(); i < n; ++i) { keyboardHelper.sendChar(text.charAt(i)); } } } }
Example 3
Source File: NotificationPlatformBridge.java From AndroidChromium with Apache License 2.0 | 5 votes |
@Nullable private static String getNotificationReply(Intent intent) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) { // RemoteInput was added in KITKAT_WATCH. Bundle remoteInputResults = RemoteInput.getResultsFromIntent(intent); if (remoteInputResults != null) { CharSequence reply = remoteInputResults.getCharSequence(NotificationConstants.KEY_TEXT_REPLY); if (reply != null) { return reply.toString(); } } } return null; }
Example 4
Source File: NotificationBroadcastReceiver.java From linphone-android with GNU General Public License v3.0 | 5 votes |
private CharSequence getMessageText(Intent intent) { Bundle remoteInput = RemoteInput.getResultsFromIntent(intent); if (remoteInput != null) { return remoteInput.getCharSequence(Compatibility.KEY_TEXT_REPLY); } return null; }
Example 5
Source File: MainActivity.java From AndroidWearable-Samples with Apache License 2.0 | 5 votes |
@Override protected void onResume() { super.onResume(); if (getIntent() != null) { Bundle inputResults = RemoteInput.getResultsFromIntent(getIntent()); if (inputResults != null) { CharSequence replyText = inputResults.getCharSequence(KEY_REPLY); if (replyText != null) { Toast.makeText(this, TextUtils.concat(getString(R.string.reply_was), replyText), Toast.LENGTH_LONG).show(); } } } }
Example 6
Source File: MessagingBuilder.java From decorator-wechat with Apache License 2.0 | 4 votes |
@Override public void onReceive(final Context context, final Intent proxy) { final PendingIntent reply_action = proxy.getParcelableExtra(EXTRA_REPLY_ACTION); final String result_key = proxy.getStringExtra(EXTRA_RESULT_KEY), reply_prefix = proxy.getStringExtra(EXTRA_REPLY_PREFIX); final Uri data = proxy.getData(); final Bundle results = RemoteInput.getResultsFromIntent(proxy); final CharSequence input = results != null ? results.getCharSequence(result_key) : null; if (data == null || reply_action == null || result_key == null || input == null) return; // Should never happen final String key = data.getSchemeSpecificPart(), original_key = proxy.getStringExtra(EXTRA_ORIGINAL_KEY); if (BuildConfig.DEBUG && "debug".equals(input.toString())) { final Conversation conversation = mController.getConversation(proxy.getIntExtra(EXTRA_CONVERSATION_ID, 0)); if (conversation != null) showDebugNotification(conversation, "Type: " + conversation.typeToString()); mController.recastNotification(original_key != null ? original_key : key, null); return; } final CharSequence text; if (reply_prefix != null) { text = reply_prefix + input; results.putCharSequence(result_key, text); RemoteInput.addResultsToIntent(new RemoteInput[]{ new RemoteInput.Builder(result_key).build() }, proxy, results); } else text = input; final ArrayList<CharSequence> history = SDK_INT >= N ? proxy.getCharSequenceArrayListExtra(EXTRA_REMOTE_INPUT_HISTORY) : null; try { final Intent input_data = addTargetPackageAndWakeUp(reply_action); input_data.setClipData(proxy.getClipData()); reply_action.send(mContext, 0, input_data, (pendingIntent, intent, _result_code, _result_data, _result_extras) -> { if (BuildConfig.DEBUG) Log.d(TAG, "Reply sent: " + intent.toUri(0)); if (SDK_INT >= N) { final Bundle addition = new Bundle(); final CharSequence[] inputs; final boolean to_current_user = Process.myUserHandle().equals(pendingIntent.getCreatorUserHandle()); if (to_current_user && context.getPackageManager().queryBroadcastReceivers(intent, 0).isEmpty()) { inputs = new CharSequence[] { context.getString(R.string.wechat_with_no_reply_receiver) }; } else if (history != null) { history.add(0, text); inputs = history.toArray(new CharSequence[0]); } else inputs = new CharSequence[] { text }; addition.putCharSequenceArray(EXTRA_REMOTE_INPUT_HISTORY, inputs); mController.recastNotification(original_key != null ? original_key : key, addition); } markRead(key); }, null); } catch (final PendingIntent.CanceledException e) { Log.w(TAG, "Reply action is already cancelled: " + key); abortBroadcast(); } }
Example 7
Source File: RemoteInputCompatApi20.java From adt-leanback-support with Apache License 2.0 | 4 votes |
static Bundle getResultsFromIntent(Intent intent) { return RemoteInput.getResultsFromIntent(intent); }