2.3 The machine can receive phone status, call the broadcast numbers, receiving less than 4.0, the other did not test, solving What is the situation? After the system is not listening to, abortBroadcast () out?
<-! Baidu Button BEGIN -> more Share to: <-! Baidu Button END ->
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) -> Reply: Make sure these two permissions:
Then determine BroadcastReceiver have not registered on. android.intent.action.PHONE_STATE not orderly broadcasting, if the above two no problem, should be able to received. android.intent.action.NEW_OUTGOING_CALL is orderly broadcasting, if suspicion by other applications abort the case, put your BroadcastReceiver to set a higher priority, if you can receive it.
Reply: Permissions are added, I was in AndroidManifest.xml, Registered should be no problem, but still does not receive this broadcast android.intent.action.PHONE_STATE priority over common sense, then I have Integer.MAXVALUE, the result was not receiving to Reply: Priority is only useful for the orderly broadcast. Android.intent.action.NEW_OUTGOING_CALL receive this broadcast it? Reply: Both are not received, a broadcast Broadcas receives two action settings should be no problem, right? Reply: Look at the code posted Reply: I was registered directly in the AndroidManifest.xml
Virtual machine test, the real machine failure
Reply:
I was directly in AndroidManifest.xml registration:
public class MyReceiver extends BroadcastReceiver {
@ Override public void onReceive (Context context, Intent intent) { System.out.println ("-----------------------------"); / / If the call if (intent.getAction (). equals (Intent.ACTION_NEW_OUTGOING_CALL)) { String phoneNumber = intent . GetStringExtra (Intent.EXTRA_PHONE_NUMBER); System.out.println ("call:" + phoneNumber); } Else { / / If the caller TelephonyManager tm = (TelephonyManager) context . GetSystemService (Service.TELEPHONY_SERVICE); tm.listen (listener, PhoneStateListener.LISTEN_CALL_STATE); } }
PhoneStateListener listener = new PhoneStateListener () { @ Override public void onCallStateChanged (int state, String incomingNumber) { / / Note that the method must be written on the back super method, otherwise incomingNumber not get to the value. super.onCallStateChanged (state, incomingNumber); switch (state) { case TelephonyManager.CALL_STATE_IDLE: Log.e ("-----------", "hang up"); break; case TelephonyManager.CALL_STATE_OFFHOOK: Log.e ("-----------", "answer"); break; case TelephonyManager.CALL_STATE_RINGING: Log.e ("-----------", "Ring: Caller ID" + incomingNumber); / / Output Caller ID break; } } };
}
Reply: I also found this problem, the real machine can not receive Reply:
I also found this problem, the real machine can not receive
I can use the machine to test 2.3, 3.0, did not try, there can be more than the 4.0 Reply:
I also found this problem, the real machine can not receive
I can use the machine to test 2.3, 3.0, did not try, can not be more than 4.0
Well, also a friend asked me to say a real machine can not receive previously been a simulator can be, the real machine test it really is not, I do not know who to call to get to the show is how very puzzled Reply:
Yes, ah, do not know the internal phone developers made a deal. Reply: This application is not without your Activity? 4.0 After this situation is limited, an APK if no Activity, only the Receiver or Service, Service or the Receiver is not activated, it can not receive broadcasts. This restriction is to prevent some rogue software in the background recklessly. Reply:
you this application is not no Activity? 4.0 After this situation is limited, an APK if no Activity, only the Receiver or Service, Service or the Receiver is not activated, it can not receive broadcasts. This restriction is to prevent some rogue software in the background recklessly.
Yes, but when I set the Activity can not receive. Reply:
This application is not without your Activity? 4.0 After this situation is limited, an APK if no Activity, only the Receiver or Service, Service or the Receiver is not activated, it can not receive broadcasts. This restriction is to prevent some rogue software in the background recklessly.
Yes, but when I set the Activity can not receive.
Activity to receive broadcasts after starting it? Reply: If the Activity never start too, but also receive broadcasts. Unless it is a system application. Reply: Started, and I started to start a Activity, registered broadcast Activity inside, and then call the phone did not respond. Reply:
started, I started a start Activity, registered broadcast Activity inside, and then call the phone no response.
Your radio is not registered it in the Manifest Reply:
Started, and I started to start a Activity, registered broadcast Activity inside, and then call the phone did not respond.
Your radio is not registered in the Manifest in it
I want to register in the Manifest inside. Found not behind, so I tested both ways, to no avail. Reply:
Started, and I started to start a Activity, registered broadcast Activity inside, and then call the phone did not respond.
Your radio is not registered in the Manifest in it
I want to register in the Manifest inside. Found not behind, so I tested both ways, to no avail.
Manifest broadcast or on the inside to register. Then your application to have a Activity, boot you run this Activity. After it has been able to receive the broadcast. Reply:
Started, and I started to start a Activity, registered broadcast Activity inside, and then call the phone did not respond.
Your radio is not registered in the Manifest in it
I want to register in the Manifest inside. Found not behind, so I tested both ways, to no avail.
Manifest broadcast or on the inside to register. Then your application to have a Activity, boot you run this Activity. After it has been able to receive the broadcast.
Well, still no effect Reply: Reply:
You have your own tests? The phone is not a problem? Reply: I tried it, yes. Code stickers to give you reference. Broadcast Receiver:
@ Override public boolean onCreateOptionsMenu (Menu menu) { / / Inflate the menu; this adds items to the action bar if it is present .getMenuInflater () inflate (R.menu.activity_main, menu);. return true; }
No comments:
Post a Comment