我目前正在开发一个使用 abroadcastreceiver
来检查传入短信的应用程序,但突然间它似乎停止工作了,我什至编写了一个小型测试应用程序,至少对我来说,它在语法上似乎是正确的,但也是不工作。
以下是来自测试项目的代码:
清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.AGApplications.test"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
<activity android:name=".test"
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=".MsgMon">
<intent-filter>
<action android:name=
"android.provider.Telephony.SMS_RECEIVED" />
</intent-filter>
</receiver>
</application>
<uses-permission android:name="android.permission.RECEIVE_SMS">
</uses-permission>
<uses-sdk android:minSdkVersion="8" />
</manifest>
广播接收器:
package com.AGApplications.test;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
public class MsgMon extends BroadcastReceiver{
@Override
//Called when new message is received
public void onReceive(Context context, Intent intent) {
Log.d("PHONE", "Message Received");
}
}
主要活动:
package com.AGApplications.test;
import android.app.Activity;
import android.os.Bundle;
public class test extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
据我所知,我没有做错任何事,但显然我是!