是否可以从意图调用方法?
是否可以从 Intent
调用方法? 我需要调用我构建的通知方法,并且它必须在此活动中。
Intent locationNotific = new Intent("SendProximityIntent");
locationNotific.putExtra("RowID", id);
sendBroadcast(locationNotific);
PendingIntent lPendingIntent = PendingIntent.getActivity(this, 0,
locationNotific, 0);
lm.addProximityAlert((double) locationAlertGeoP.getLatitudeE6(),
(double) locationAlertGeoP.getLongitudeE6(),
(float) 999999999,(long) 100000, lPendingIntent);
Is it possible to call a method from an Intent
?
I need to call an notification method that I build and it has to be in this activity.
Intent locationNotific = new Intent("SendProximityIntent");
locationNotific.putExtra("RowID", id);
sendBroadcast(locationNotific);
PendingIntent lPendingIntent = PendingIntent.getActivity(this, 0,
locationNotific, 0);
lm.addProximityAlert((double) locationAlertGeoP.getLatitudeE6(),
(double) locationAlertGeoP.getLongitudeE6(),
(float) 999999999,(long) 100000, lPendingIntent);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,但您可以在意图中添加一个具有特定值的额外字段。当活动启动时,解析额外的字段,如果找到该值,则调用所需的方法。例如:
在您的活动中:
希望这会有所帮助。
No, but you can put an extra field the intent with a specific value. When the activity starts, parse the extra field and, if the value is found, call the desired method. Something like:
And in your activity:
Hope this help.