在广播接收器中,我想启动我的应用程序(Activity)并传入一些数据.
我的问题是额外的东西似乎没有延续到活动中.我试图获取onNewIntent(Intent i)函数内的数据.
有任何想法吗?
这是我目前在broadcastReceiver中的尝试:
Intent intSlider = new Intent(); intSlider.setClass(UAirship.shared().getApplicationContext(),SliderMenuActivity.class); intSlider.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intSlider.putExtra("action",ScreensEnum.Object); intSlider.putExtra("objectId",objectId); intSlider.putExtra("objectCode",objectCode); intSlider.putExtra("userId",userId); UAirship.shared().getApplicationContext().startActivity(intSlider);
编辑 – 添加了onNewIntent()和onCreate()中使用的代码
当应用程序当前未运行时,以下代码在onCreate()中运行良好.当应用程序已经运行时,相同的代码不能从onNewIntent()函数中起作用(即没有额外的).
Intent intent = getIntent(); if(intent.hasExtra("objectId")) { loadDetail(intent.getStringExtra("objectId"),"2w232"); }
解决方法
原文地址:https://www.jb51.cc/android/308602.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。