问题描述
这个问题在某种程度上涉及到这个问题时,我一直在寻找get临时演员早在startActivityForResult 但现在我面临的另一挑战。
This questions somehow relates to the question when I was looking to get the extras back in startActivityForResult but now I face another challenge.
我已经订阅接收ProximityAlerts,我已经明确地构建了意向,包括一些附加功能。但是,当我得到了服务群众演员不存在。
I have subscribed to receive ProximityAlerts and I have explicitly constructed the Intent to include some Extras. But when I got the service the extras are not there.
后这里的答案是工作code:
Intent intent = new Intent(this, PlacesProximityHandlerService.class);
intent.setAction("PlacesProximityHandlerService");
intent.putExtra("lat", objPlace.getLat());
intent.putExtra("lon", objPlace.getLon());
intent.putExtra("error_m", objPlace.getError()+ALERT_RANGE_IN_METERS);
PendingIntent sender=PendingIntent.getService(this, 0, intent, 0);
LocationUtils.addProximity(this, objPlace.getLat(), objPlace.getLon(),objPlace.getError()+ALERT_RANGE_IN_METERS, -1, sender);
该文件说,参数 PendingIntent要发送的每个位置更新
推荐答案
对于一些不明原因,临时演员将只提供,如果你已经设置了一些措施,例如的setAction(富)。什么CommonsWare指的是仅适用于获得PendingIntent情况下,如果您没有设置FLAG_ONE_SHOT。这可以固定在PendingIntent.get请求code的说法......工厂方法。虽然文件说,目前不能使用的,它实际上区分PendingIntents时,考虑到计数。
For some unspecified reason, extras will be delivered only if you've set some action, for example setAction("foo"). What CommonsWare refers to applies only when obtaining PendingIntent instances, if you haven't set FLAG_ONE_SHOT. That can be fixed by the requestCode argument in PendingIntent.get... factory methods. Although documentation says it's currently not used, it actually takes into count when distinguishing PendingIntents.
在你的情况,你不需要设置任何东西比一些假动作字符串。 LocationManagerService重用你已经认购接近警报的PendingIntent,只增加了一个标志,如果手机已经进入或退出报警范围。
In your case, you don't need to set anything else than some dummy action string. LocationManagerService reuses the PendingIntent you have subscribed for proximity alerts, and only adds a flag if phone has entered or exited the alarm range.
这篇关于为什么PendingIntent没有送回我的自定义设置额外的意图是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!