我试图启动一个新的应用程序,但我需要知道有关电话状态的变化... 由于某种原因(我是新来的)我不能捕捉广播改变。 这就是我的代码:BroadcastReceiver不接电话状态
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
public class MyReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.d("TAG","yyyyyyyyyyyy");
}
}
和这就是我的清单:
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<receiver
android:name=".MyReceiver">
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE"/>
</intent-filter>
</receiver>
</application>
,你可以看到... ...很简单。 但我无法看到在我的LogCat onreceive登录。 任何人都知道为什么? 谢谢!
代码似乎没问题,您确定的日志没有打印?>您在logcat中看到了什么 – AAnkit 2012-07-26 16:11:56