2014-05-09 64 views
1

我已经创建了下面的自定义广播接收器的代码是自定义广播接收器在调用两次安卓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两次:(

+0

它怎么可能我的朋友??? –

+0

所以你打电话给sendBroadcast两次? – pskink

+0

没有我的朋友每一个发送广播我越来越接收 –

回答

0

这意味着你得到两个b具有相同意图的广播

com.example.parsepushexample.UPDATE_STATUS 

检查发送广播的逻辑,必须有一些问题。

检查以下soultion从This Link

卸下有效载荷警告标签,解决

由于这个线程

https://www.parse.com/questions/how-suppress-push-notification-from-being-displayed

+0

雅:(我检查我发送pushnotification从解析.com和我看不到在那 –

+0

我编辑了我的答案 – Akhil

+0

如何删除警报有效载荷 –