http://developer.android.com/reference/android/provider/VoicemailContract.html
我不知道如何用 VOICEMAIL 制作广播接收器。当您收到语音邮件时,您会在通知中看到“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 中看不到“语音邮件”。