添加意图活动动态 [英] Adding intent to activity dynamically

查看:92
本文介绍了添加意图活动动态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经得到了我已经在AndroidManifest.xml静态定义的一个意图过滤器的活动。我想注册其他意图动态地在活动的调用onStart()方法,目的相同的过滤器。这可能吗?我试图避免实施单独的意图接收器类。


解决方案

  

这可能吗?


没有,对不起。


  

我试图避免实施单独的意图接收器类。


您没有选择 - 一个意图 sendBroadcast()不会由接收使用活性的任何其他方式。不要混淆 startActivity() 意图 sendBroadcast() 意图

I've got an activity for which I've defined an intent filter statically in AndroidManifest.xml. I'd like to register additional intents dynamically to that same intent filter in the activity's onStart() method. Is this possible? I'm trying to avoid having to implement a separate intent receiver class.

解决方案

Is this possible?

No, sorry.

I'm trying to avoid having to implement a separate intent receiver class.

You have no choice -- an Intent used with sendBroadcast() is not going to be received by an activity any other way. Do not confuse startActivity() Intents with sendBroadcast() Intents.

这篇关于添加意图活动动态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆