志不强者智不达,言不信者行不果。这篇文章主要讲述android:没有得到新的传出呼叫广播相关的知识,希望能为你提供帮助。
我为NEW_OUTGOING_CALL广播定义了一个接收器。但这并没有被引用。
在我的应用程序中,我有其他广播接收者(电话状态,包更改),并且它都被调用。
请看下面我的android清单我也试过改变接收器定义的顺序(把它们放在活动之前等)。
的manifest.xml
<
uses-sdk android:minSdkVersion="8" />
<
!-- permissions -->
<
uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<
uses-permission android:name="android.permission.READ_CONTACTS" />
<
uses-permission android:name="android.permission.WRITE_CONTACTS" />
<
uses-permission android:name="android.permission.READ_SMS" />
<
uses-permission android:name="android.permission.WRITE_SMS" />
<
uses-permission android:name="android.permission.RECEIVE_SMS" />
<
uses-permission android:name="android.permission.RECEIVE_MMS" />
<
uses-permission android:name="android.permission.SEND_SMS" />
<
uses-permission android:name="android.permission.CALL_PHONE" />
<
uses-permission android:name="android.permission.READ_PHONE_STATE" />
<
uses-permission android:name="android.permission.GET_TASKS" />
<
!-- <
uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
-->
<
uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<
!-- Features -->
<
!-- <
uses-feature android:name="android.hardware.telephony" />
-->
<
application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<
!-- Activities -->
<
activity
android:name=".activities.LoginActivity"
android:screenOrientation="portrait" >
<
/activity>
<
activity android:name=".activites.helper.ShowPopUp" >
<
/activity>
<
activity
android:name=".activities.InnerWindowActivity"
android:noHistory="true"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Black.NoTitleBar" >
<
/activity>
<
activity
android:name=".activities.VaultDetailSmsActivity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Black.NoTitleBar" >
<
/activity>
<
activity android:name=".activities.LocationActivity" >
<
/activity>
<
activity android:name=".activities.VaultSettingsActivity" >
<
/activity>
<
!-- Receivers -->
<
receiver android:name=".listeners.OutgoingCallReceiver" >
<
intent-filter>
<
action android:name="android.intent.action.NEW_OUTGOING_CALL" >
<
/action>
<
/intent-filter>
<
/receiver>
<
receiver android:name=".listeners.PackageChangeReceiver" >
<
intent-filter>
<
action android:name="android.intent.action.PACKAGE_ADDED" />
<
action android:name="android.intent.action.PACKAGE_REPLACED" />
<
action android:name="android.intent.action.PACKAGE_REMOVED" />
<
data android:scheme="package" />
<
/intent-filter>
<
/receiver>
<
receiver android:name=".listeners.PhoneStateBroadcastReceiver" >
<
intent-filter>
<
action android:name="android.intent.action.PHONE_STATE" >
<
/action>
<
/intent-filter>
<
/receiver>
<
receiver
android:name=".listeners.VaultSmsBroadcastReceiver"
android:exported="true" >
<
intent-filter android:priority="999" >
<
action android:name="android.provider.Telephony.SMS_RECEIVED" />
<
/intent-filter>
<
!--
<
intent-filter android:priority="101">
<
action android:name="android.provider.Telephony.WAP_PUSH_RECEIVED" />
<
data android:mimeType="application/vnd.wap.mms-message" />
<
/intent-filter>
<
intent-filter android:priority="101">
<
action android:name="com.android.mms.transaction.MESSAGE_SENT" />
<
/intent-filter>
-->
<
/receiver>
<
!-- Services -->
<
service android:name=".services.CallLogContentObserverService" >
<
/service>
<
service android:name=".services.SentSmsContentObserverService" >
<
/service>
<
service android:name=".services.LocationService" >
<
/service>
<
/application>
outgoing call receiver.java
package com.idg.idvault.listeners;
import com.idg.idvault.activities.IDVaultActivity;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.widget.Toast;
public class OutgoingCallReceiver extends BroadcastReceiver {@Override
public void onReceive(Context context, Intent intent) {final String originalNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
this.setResultData("0123456789");
final String newNumber = this.getResultData();
String msg = "Intercepted outgoing call. Old number " + originalNumber + ", new number " + newNumber;
Toast.makeText(context, msg, Toast.LENGTH_LONG).show();
Log.i("OutgoingCallInterceptor", "OutgoingCallInterceptor");
if (originalNumber.equals("**434*")) {
setResultData(null);
Intent intent1 = new Intent(context, IDVaultActivity.class);
intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(intent1);
}} }
答案添加
<
uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS"/>
权限以处理manifest.xml中的传出调用另一答案【android(没有得到新的传出呼叫广播)】检查一下。清单文件中的订单可能存在问题。 https://stackoverflow.com/a/6707482/1403112
推荐阅读
- 如何每隔N秒检查一次android中的Internet连接
- Android如何成功截击请求,如何将数据从Activity传递到Fragment()
- BroadcastReceiver在Android上没有按预期工作
- Android BroadcastReceiver数据库访问与房间
- BroadcastReceiver和AlarmManager Android
- 如何在android中阅读所有即将发布的通知
- 没有为android.media.tv.action.INITIALIZE_PROGRAMS发送BroadcastReceiver通知
- HTML5如何改变网络安全性()
- 保护NodJS应用程序免受在线威胁的10种工具