我正在执行以下代码以收听传入的短信 它不起作用,我从未接触到接收器类。
我正在使用i1(Android 1.5)
一些代码:
Manifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<receiver android:name=".SmsReceiver">
<intent-filter>
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
<
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
</application>
<uses-sdk android:minSdkVersion="3" />
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>
这是播音员课程:
public class SmsReceiver extends BroadcastReceiver
{
@Override
public void onReceive(Context arg0, Intent arg1)
{
Log.d("SmsReceiver", "I GOT THE SMS");
}
}
将短信发送到手机后,上面的一行从未在Logcat上打印过。
知道我做错了什么吗?
感谢,
射线。
答案 0 :(得分:1)
您能否在清单中显示接收器的确切位置?
也许看看这里: BroadcastReceiver + SMS_RECEIVED
答案 1 :(得分:1)
您在哪里注册接收器? You need to call registerReceiver(yourReceiver, new IntentFilter(SMS_RECEIVED).
答案 2 :(得分:1)
删除了/ application标记之外的权限