android 使用BroadcastReceiver 接收模拟短信报错

小弟初学android
写了一个类用来接收模拟器发送的短信:
public class SMSReceiver extends BroadcastReceiver{

@Override
public void onReceive(Context context, Intent intent) {
Bundle bundle = intent.getExtras();
Object messages[] = (Object[])bundle.get("pdus");
SmsMessage[] smsMessage = new SmsMessage[messages.length];
for(int i=0;i<messages.length;i++){
smsMessage[i] = SmsMessage.createFromPdu((byte[])messages[i]);
}
Toast toast = Toast.makeText(context, smsMessage[0].getMessageBody(), Toast.LENGTH_LONG);
toast.show();

}

}
AndroidManifest.xml 配置文件内容
<application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".HelloWorld"
                  android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
       
        <receiver android:name=".SMSReceiver" android:enabled="true"> 
<intent-filter> 
<action android:name="android.provider.Telephony.SMS_RECEIVED"/> 
</intent-filter> 
</receiver>
    </application>
模拟接收短信时
LogCat后台抛出异常:
could't open fd for content://setting//system/notification_sound
详解见附件,请各位帮忙看一下。

问题补充
没人知道吗?

查看全部
c364902709
江湖一码农
2011/05/24 16:59
  • android
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

0个回复