本文整理汇总了Java中android.app.RemoteInput.getResultsFromIntent方法的典型用法代码示例。如果您正苦于以下问题:Java RemoteInput.getResultsFromIntent方法的具体用法?Java RemoteInput.getResultsFromIntent怎么用?Java RemoteInput.getResultsFromIntent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.RemoteInput
的用法示例。
在下文中一共展示了RemoteInput.getResultsFromIntent方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onReceive
import android.app.RemoteInput; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
// Get remote input
Bundle remoteInput = RemoteInput.getResultsFromIntent(intent);
// Exit if remote input is null (always true for API < 24)
if (remoteInput == null) {
return;
}
// Get reply text
String reply = remoteInput.getString(KEY_TEXT_REPLY);
// Create reply notification
Notification replyNotification =
new Notification.Builder(context)
.setSmallIcon(R.drawable.ic_notifications_active_black_24dp)
.setContentTitle("Reply received!")
.setContentText(reply)
.build();
// Send reply notification
NotificationManager notificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify(REPLY_NOTIFICATION_ID, replyNotification);
}
示例2: getNotificationReply
import android.app.RemoteInput; //导入方法依赖的package包/类
@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;
}
示例3: getNotificationReply
import android.app.RemoteInput; //导入方法依赖的package包/类
@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;
}
示例4: onReceive
import android.app.RemoteInput; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
Log.d ( TAG, "onReceive()..." + new Date() ) ;
String voiceReplyContent = "No reply";
Bundle remoteInputBundle = RemoteInput.getResultsFromIntent(intent);
Log.d ( TAG, "onReceive() remoteInputBundle=" + remoteInputBundle ) ;
if (remoteInputBundle != null) {
CharSequence charSequence = remoteInputBundle.getCharSequence(EXTRA_VOICE_REPLY) ;
voiceReplyContent = charSequence.toString() ;
}
Log.d ( TAG, "onReceive()... voiceReplyContent=" + voiceReplyContent ) ;
// originate notification that will end up showing on the handheld
Notification notification = new Notification.Builder(context)
.setSmallIcon(R.drawable.alarm36)
.setContentTitle("From Head unit")
.setContentText( voiceReplyContent )
.setColor( context.getResources().getColor(R.color.colorPrimary)).build() ;
NotificationManager notificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.notify( 7200, notification );
}
示例5: onResume
import android.app.RemoteInput; //导入方法依赖的package包/类
@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();
}
}
}
}
示例6: onCreate
import android.app.RemoteInput; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_voice_input_result);
tvResult = (TextView) findViewById(R.id.tv_activity_voice_input_result);
Bundle remoteInput = RemoteInput.getResultsFromIntent(getIntent());
if(remoteInput!=null){
CharSequence result = remoteInput.getCharSequence(KEY_VOICE_INPUT);
tvResult.setText(result);
}
}
示例7: getResultsFromIntent
import android.app.RemoteInput; //导入方法依赖的package包/类
static Bundle getResultsFromIntent(Intent intent) {
return RemoteInput.getResultsFromIntent(intent);
}
示例8: a
import android.app.RemoteInput; //导入方法依赖的package包/类
public final Bundle a(Intent paramIntent)
{
return RemoteInput.getResultsFromIntent(paramIntent);
}
示例9: onReceive
import android.app.RemoteInput; //导入方法依赖的package包/类
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "onReceive()... intent=" + intent) ;
Bundle remoteVoiceInputBundle = RemoteInput.getResultsFromIntent(intent) ;
String voiceInputAsText = null ;
try {
voiceInputAsText = remoteVoiceInputBundle.getCharSequence( VOICE_INPUT_KEY).toString() ;
} catch ( Throwable t) {
Log.w ( TAG, "onReceive()... throwable/exception=" + t) ;
}
Log.d(TAG, "onReceive()... received from Wear device, voiceInputAsText=" + voiceInputAsText) ;
if ( voiceInputAsText != null ) {
startActivity ( context, voiceInputAsText ) ;
}
}
示例10: getResultsFromIntent
import android.app.RemoteInput; //导入方法依赖的package包/类
static Bundle getResultsFromIntent(Intent intent)
{
return RemoteInput.getResultsFromIntent(intent);
}