我已经创建了下面的自定义广播接收器的代码是自定义广播接收器在调用两次安卓parse.com
public class MyCustomReceiver extends BroadcastReceiver {
private static final String TAG = "MyCustomReceiver";
@Override
public void onReceive(Context context, Intent intent) {
try {
if (intent.getAction() != null
&& intent.getAction().equals(
"com.example.parsepushexample.UPDATE_STATUS")) {
System.out.println("call MyReceiver onRecive method");
Intent intent2 = new Intent(context, MyCallService.class);
context.startService(intent2);
System.out.println("service started over");
}
} catch (Exception e) {
Log.d(TAG, "JSONException: " + e.getMessage());
}
}
}
和menifest文件
<receiver android:name="com.parse.ParseBroadcastReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
<receiver
android:name="com.example.parsepushexample.MyCustomReceiver"
android:exported="false" >
<intent-filter>
<action android:name="com.example.parsepushexample.UPDATE_STATUS" />
</intent-filter>
</receiver>
<service android:name="MyCallService"></service>
而且我收到通知,但我的问题是那每次都会调用onreceive两次:(
它怎么可能我的朋友??? –
所以你打电话给sendBroadcast两次? – pskink
没有我的朋友每一个发送广播我越来越接收 –