http://developer.android.com/reference/android/provider/VoicemailContract.html
我不知道如何用VOICEMAIL制作一个brocast接收器。当您收到语音邮件时,您会在通知中看到“NEW VOICEMAIL”,该图标就像磁带一样。
这是我的代码:
的AndroidManifest.xml
<receiver android:name=".VoiceBrocast" >
<intent-filter>
<action android:name="android.intent.action.NEW_VOICEMAIL" />
</intent-filter>
</receiver>
<uses-permission android:name="com.android.voicemail.permission.ADD_VOICEMAIL" />
我试图在xx.java中注册,但它没有用。
MainActivity.java:
protected VoiceBrocast mUiBroadcastReceiver;
mUiBroadcastReceiver = new VoiceBrocast();
IntentFilter mIntentFilter = new IntentFilter();
mIntentFilter.addAction("android.intent.action.ACTION_NEW_VOICEMAIL");
MainActivity.this.registerReceiver(mUiBroadcastReceiver, mIntentFilter);
VoiceBrocast.Java
公共类VoiceBrocast扩展了BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
// TODO Auto-generated method stub
System.out.println("voicemail");
}
}
当我收到语音邮件时,没有什么要打印的,我在LogCat中看不到“语音邮件”。
答案 0 :(得分:0)
访问此内容提供商所需的最低权限是ADD_VOICEMAIL
你有这样的许可吗?
答案 1 :(得分:0)
不确定是否有其他错误,但有一个问题是:意图操作不是"android.intent.action.ACTION_NEW_VOICEMAIL"
而是"android.intent.action.NEW_VOICEMAIL"
。
也许你把它与VoicemailContract类的常量名称VoicemailContract.ACTION_NEW_VOICEMAIL
混合在一起。