我已經創建了下面的自定義廣播接收器的代碼是自定義廣播接收器在調用兩次安卓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
沒有我的朋友每一個發送廣播我越來越接收 –