从活动尝试发送:
Intent bcIntent = new Intent();
bcIntent.setAction("ON_TICK");
this.core.context.sendBroadcast(bcIntent);
但不起作用。 MyBroadcast:
public class ServicesBroadcastReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
// Log Action
Log.d("app_log", "ServicesBroadcastReceiver action: " + action);
设置清单XML:
<receiver
android:name=".services.ServicesBroadcastReceiver"
android:enabled="true"
android:exported="true"
android:process=":remote" >
<intent-filter> ...
我做错了什么?
答案 0 :(得分:1)
您正在创建一个Intent
,其动作字符串为"ON_TICK"
。您在<intent-filter>
的清单中没有BroadcastReceiver
,其操作字符串为"ON_TICK"
。因此,您的BroadcastReceiver
将不会收到此广播。