intent.putExtra()在等待中的意图不起作用

兔子

我正在通过服务类中的alarmreceiver传递未决的意图。但是,在未决的Intent触发之后,广播接收器类未接收到intent.putExtra()信息。这是我触发未决意图的代码

Intent aint = new Intent(getApplicationContext(), AlarmReceiver.class);
PendingIntent pendingIntent = PendingIntent.getBroadcast(getApplicationContext(), id, aint, PendingIntent.FLAG_UPDATE_CURRENT);
aint.putExtra("msg", msg);
aint.putExtra("phone", phone);
alarmManager.set(AlarmManager.RTC_WAKEUP, cal.getTimeInMillis(), pendingIntent);

警报接收器类别如下

public String msg, phonen;

@Override
public void  onReceive(Context context, Intent intent){
    Bundle extras = intent.getExtras();
    msg = extras.getString("msg");
    phonen = extras.getString("phone");

    Log.d("onReceive", "About to execute MyTask");
    Toast.makeText(context,msg, Toast.LENGTH_LONG).show();
}

没有显示从待处理的意图中接收的Toast中味精信息。而是显示了空白的吐司。

阿耶什唐

试试这个

Intent aint = new Intent(getApplicationContext(), AlarmReceiver.class);
aint.putExtra("msg", msg);
aint.putExtra("phone", phone);



PendingIntent pendingIntent = PendingIntent.getBroadcast(
    getApplicationContext(),
    id, 
    aint,
    // as stated in the comments, this flag is important!
    PendingIntent.FLAG_UPDATE_CURRENT);

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Intent和putExtra不起作用

来自分类Dev

Intent和putExtra不起作用

来自分类Dev

startActivity(intent)不起作用

来自分类Dev

Android,Intent不起作用

来自分类Dev

setResult(int,intent)在Android中不起作用

来自分类Dev

在Intent中覆盖OnActivityResult不起作用-Kotlin

来自分类Dev

intent.getStringExtra在android中不起作用

来自分类Dev

setResult(int,intent)在Android中不起作用

来自分类Dev

片段中的Intent和AlertDialog不起作用

来自分类Dev

Android Intent Clear Top不起作用

来自分类Dev

Intent.setData与Intent.putExtra

来自分类Dev

intent.putExtra有什么作用?

来自分类Dev

Intent putExtra在RecyclerView(Kotlin)的ViewHolder中

来自分类Dev

Intent.EXTRA_LOCAL_ONLY不起作用

来自分类Dev

具有Intent的Mac上的WidgetKit不起作用

来自分类Dev

使用Intent启动地图活动不起作用

来自分类Dev

Android Intent putExtra与静态调用?

来自分类Dev

新Intent中的NullPointerException

来自分类Dev

android studio中intent.getStringExtra和intent.putExtra的解释

来自分类Dev

RuntimeException:android.content.Intent中的方法putExtra不被模拟

来自分类Dev

PendingIntent发送错误的Intent / putExtra

来自分类Dev

intent.putExtra 传递空值

来自分类Dev

Intent中的TreeMap成为HashMap

来自分类Dev

Android中的Intent.setClass

来自分类Dev

Android kitkat API 19,Intent.ACTION_VIEW不起作用

来自分类Dev

适用于https方案的Android Intent过滤器不起作用

来自分类Dev

当sendBroadcast(intent)正常工作时,adb shell广播不起作用

来自分类Dev

Intent(context,Class)不起作用当我传入class对象时给出错误

来自分类Dev

startActivity(intent)它不起作用?当我的DemoActivity使用android:launchMode =“ singleTask”时,

Related 相关文章

热门标签

归档