在示例中,他们将 Intent 创建为:
Intent intent = new Intent(this, AlarmReceiver.class);
但是假设我的 AlarmReceiver 类在另一个应用程序中,我该如何创建这个 Intent?
我试过
new Intent("com.app.AlarmReceiver")
但什么也没发生..它没有被调用..
有什么想法吗?
--使用 Eclipse 上的 list 编辑器添加的广播定义:
<receiver android:name="AlarmReceiver"></receiver>
</application>
--
相关:
How do I start my app from my other app? (但同样的代码不适用于广播……)
最佳答案
But my suppose my AlarmReceiver class is in another app, how do I create this intent?
如果您编写了其他应用程序,请添加 <intent-filter>
使用自定义操作字符串发送到其他应用程序的 <receiver>
元素,然后使用 Intent
使用该操作字符串。
如果您没有编写其他应用程序,请询问编写它的人 Intent
应该看起来像。
关于android - 如何为另一个应用程序的广播接收器创建一个新的 Intent?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3319365/