当用户选择“始终”时,使用Jelly bean 4.1.1在Galaxy S3中调用拦截不起作用?

时间:2012-12-04 10:05:47

标签: android call galaxy android-4.2-jelly-bean

我成功捕获广播,如果号码符合要求,我终止此呼叫请求并再发一次,即允许用户选择弹出窗口,我的onReceive就在这里

@Override
public void onReceive(Context context, Intent intent) {
    final String oldNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);          

    final String newNumber = this.getResultData();
    boolean useAmivox = true;

    Bundle bundle = intent.getExtras();

    Log.d(DTAG, "bundle: " + bundle.toString());

    Log.d(DTAG, "Number: " + oldNumber );

    if( oldNumber != null ){
        boolean isGlobal= PhoneNumberUtils.isGlobalPhoneNumber(oldNumber);
        Log.d(DTAG, "isGlobal: " + isGlobal );
        boolean isIntl= PhoneNumberUtils.toaFromString(oldNumber)== PhoneNumberUtils.TOA_International ? true:false;
        Log.d(DTAG, "isIntl: " + isIntl );
        useAmivox = isGlobal && isIntl; 
    }
    if( oldNumber.contains(TAG))
        useAmivox=true;


    if ( !oldNumber.contains(TAG) && useAmivox) {

        setResult(Activity.RESULT_OK, null, null);
        Intent lIntent = new Intent();
        lIntent.setAction(Intent.ACTION_CALL);

        lIntent.setData(Uri.parse("tel:" + oldNumber + TAG));
        lIntent.putExtra(Intent.EXTRA_PHONE_NUMBER, oldNumber);
        lIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(lIntent);
   }else{
        if (oldNumber != null)
            setResult(Activity.RESULT_OK, oldNumber.replace(TAG, ""),
                    null);
    }
}

清单就像这样

<receiver
        android:name="com.amivox.callintercepttest.OutCallInterceptor"
        android:enabled="true"
        android:exported="true" >
        <intent-filter android:priority="10" >
            <action android:name="android.intent.action.NEW_OUTGOING_CALL" />
        </intent-filter>
</receiver>

Galaxy S3中使用果冻豆4.1.1会发生的情况是,如果用户选择电话,即不是我的应用程序,则不会进行任何调用,即我的广播接收者总是将结果设置为空。此代码自2.x以来一直在工作,如果用户选择将“默认值”设置为“手机”,我的广播接收器没有任何负面影响;)果冻仿真器测试也应该如此工作,但Galaxy S3 with Jelly豆不!是否有人遇到过同样的问题并找到了解决方案?

0 个答案:

没有答案