所以,我想开发一个自定义锁屏
So I am trying to develop a custom lockscreen
但我的广播接收器,将不会触发
but my broadcastreceiver won't fire
我的清单:
<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="schemas.android/apk/res/android" package="org.alexander.fuchs.lockscreen" android:versionCode="1" android:versionName="1.0" > <uses-sdk android:minSdkVersion="8" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/> <application android:icon="@drawable/ic_launcher" android:label="@string/app_name" > <activity android:name=".app" 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=".myreceiver"> <intent-filter> <action android:name="android.intent.action.SCREEN_OFF"/> <action android:name="android.intent.action.SCREEN_ON"/> <action android:name="android.intent.action.BOOT_COMPLETED"/> </intent-filter> </receiver> </application> </manifest>我的接收器:
public class myreceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { Log.d("receiver","works"); Toast.makeText(context,"works",Toast.LENGTH_LONG).show(); Intent in=new Intent(context,app.class); context.startActivity(in); } }接收者应该告诉我,它被激发:D但是疗法不在logcat的任何日志
the receiver should show me that it is fired :D but ther aren't any logs in logcat
推荐答案很好,在屏幕关闭,在屏幕上,这不可能是清单里,但只在运行时。看到这一点:thinkandroid.word$p$pss/2010/01/24/handling-screen-off-and-screen-on-intents/
well , for the screen off and screen on , this cannot be inside the manifest , but only at runtime . see this: thinkandroid.wordpress/2010/01/24/handling-screen-off-and-screen-on-intents/
在启动时,它必须在清单中,所以别的东西是错的it.check类的路径。这肯定是问题的原因。
for the bootup , it must be in the manifest , so something else is wrong with it.check the path of the class. this is surely the cause of the problem.
更多推荐
尝试接收bootcomplete或屏幕关闭时,Android的广播接收器不工作
发布评论