关于BroadCast的疑惑 崩溃中
新手在刚学的时候遇到问题了~
在安卓4.0.3下。
package com.matrix;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
public class SmsReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
System.out.println("收到一条新的短信");
}
}
//这是最简单的继承 我只是想让他能有个输出。
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.smsbroadcastreceiver"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="18" />
<uses-permission android:name="android.permission.RECEIVE_SMS"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<receiver android:name="com.matrix.SmsReceiver">
<intent-filter >
<action android:name="android.provider.Telephony.SMS_RECEIVED"/>
</intent-filter>
</receiver>
</application>
</manifest>
//清单文件如上所示 一切都配置好了。
我的问题是:安装到模拟器上
014-08-14 17:17:48 - SmsBroadcastReceiver] No Launcher activity found!
[2014-08-14 17:17:48 - SmsBroadcastReceiver] The launch will only sync the application package on the device!
[2014-08-14 17:17:48 - SmsBroadcastReceiver] Performing sync
[2014-08-14 17:17:48 - SmsBroadcastReceiver] Automatic Target Mode: Unable to detect device compatibility. Please select a target device.
[2014-08-14 17:17:58 - SmsBroadcastReceiver] Application already deployed. No need to reinstall.
[2014-08-14 17:17:58 - SmsBroadcastReceiver] \SmsBroadcastReceiver\bin\SmsBroadcastReceiver.apk installed on device
[2014-08-14 17:17:58 - SmsBroadcastReceiver] Done!
安装成功 可是当收到短信 系统发出广播时 程序无法调用onReceive函数。根本进不去。
LogCat也没有任何显示system.out的东西。 感觉程序根本没有启动,只是装了一个包上去而已。
没有activity 安装之后程序启动了吗? 我在Device专用也没看到程序的进程。
查了一天不知道原因。。。
求大神帮忙看看!
PS:在有activity的demo里动态注册时可以收到广播的。