2015-02-02 2 views
5

최대 Android 휴대 전화 상태 방송 수신기가 작동합니다. 안드로이드 lolipop 전화 상태 방송 수신기에서 여러 방송을 보내는. Android Lolipop에서 변경된 사항이 있습니까?Android Lollipop은 전화 상태 변경을 위해 여러 개의 BroadcastReceivers를 보냅니다.

public class PhoneStateBroadcastReceiver extends BroadcastReceiver { 

    @Override 
    public void onReceive(Context context, Intent intent) { 
    String state = intent.getStringExtra(TelephonyManager.EXTRA_STATE); 
    Log.d("PhoneState", state); 
    } 
} 
} 

    <receiver android:name="com.phonestate.PhoneStateBroadcastReceiver" > 
     <intent-filter> 
      <action android:name="android.intent.action.PHONE_STATE" /> 
     </intent-filter> 
    </receiver> 
+0

내가 의도라고 구독 전송 여분이 발견, 그리고 1 개 또는 9223372036854775807. 내 생각은, 버그 것 같다? – gerfmarquez

+0

숫자는 Long.MAX_VALUE입니다. 왜 이런 일이 일어 났는가? – Muzikant

+0

이 문제에 대한 버그 보고서를 게시했습니다 : https://code.google.com/p/android/issues/detail?id=161508 – Muzikant

답변

0

: 그것은 모두에서 작동

public void onReceive(Context context, Intent intent) { 
    long subId = intent.getLongExtra("subscription", Long.MIN_VALUE); 
    if(subId < Integer.MAX_VALUE) { 
    // hurray, this is called only once on all operating system versions! 
    } 
} 

는 5.x를 4.x의 앞으로 호환되어야합니다. 자세한 내용은 내 블로그를 참조하십시오

http://www.skoumal.net/en/android-duplicated-phone-state-broadcast-on-lollipop/

관련 문제