NEW_OUTGOING_CALL not being called on Samsung Galaxy S

北战南征 提交于 2019-12-01 03:42:26

问题


Trying to intercept outgoing calls, and have a solution working well on

  • nexus 1 stock android 2.2
  • HTC desire 2.2
  • Moto defy 2.1

But not on the Samsung Galaxy S running 2.1, anyone seen this?

 <receiver  android:name="com.mypackge.OutGoingCallDetection" 
    android:exported="true"> 
 <intent-filter>   
  <action
    android:name="android.intent.action.NEW_OUTGOING_CALL"
    android:priority="0" /> 
</intent-filter> 
</receiver>
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" /> 

Update: the PROCESS_OUTGOING_CALLS is also added.

The receiver:

public class OutGoingCallDetection extends BroadcastReceiver {

    private static final String TAG = "OutGoingCallDetection";


    @Override
    public void onReceive(Context context, Intent intent) {

        String action = intent.getAction();
        Log.d(TAG, "onReceive, Action:" +intent.getAction());
    }
}

回答1:


Try putting the manifest in order as suggested by Google Dev: Manifest.xml

Like this:

<uses-permission />
...
<receiver>
    <intent-filter> . . . </intent-filter>
    <meta-data />
</receiver>

There may be an issue in how some devices parse the Manifest and may not register the receiver correctly.

EDIT: As of ADT 16 Lint will tell you that your permissions are in the wrong place, so I'm assuming this must be more of an issue then previously thought

Cheers




回答2:


You need to add the user permission:

<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" /> 

See this blog post as an example of how to setup and use the NEW_OUTGOING_CALL.

Also see this blog post as to what to set your android:priority to.




回答3:


Did you tried to increase android:priority? Let's say up to 10000.

I was intercepting incoming SMS' and increasing of android:priority attribute was helpful




回答4:


I created the broadcast listener programmatically. It works fine. For your reference.

IntentFilter filter = new IntentFilter();
filter.addAction("android.intent.action.NEW_OUTGOING_CALL");

receiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
        Log.d(TAG, "onReceive, Action:" +intent.getAction());
    }
};
registerReceiver(receiver, filter);


来源:https://stackoverflow.com/questions/6696652/new-outgoing-call-not-being-called-on-samsung-galaxy-s

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!