我无法从UI线程发送广播操作

时间:2015-07-27 21:56:51

标签: android

从活动尝试发送:

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> ...

我做错了什么?

1 个答案:

答案 0 :(得分:1)

您正在创建一个Intent,其动作字符串为"ON_TICK"。您在<intent-filter>的清单中没有BroadcastReceiver,其操作字符串为"ON_TICK"。因此,您的BroadcastReceiver将不会收到此广播。