use*_*184 0 android intentfilter broadcastreceiver android-intent
所以我正在尝试开发自定义锁屏
但我的广播接收器不会发射
我的清单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/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>
Run Code Online (Sandbox Code Playgroud)
我的接收者:
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);
}
}
Run Code Online (Sandbox Code Playgroud)
接收器应该告诉我它被触发:D但是它不是logcat中的任何日志
好吧,对于屏幕关闭和屏幕打开,这不能在清单内,而只能在运行时.看到这个:http: //thinkandroid.wordpress.com/2010/01/24/handling-screen-off-and-screen-on-intents/
对于启动,它必须在清单中,所以其他错误.检查类的路径.这肯定是问题的原因.
| 归档时间: |
|
| 查看次数: |
6874 次 |
| 最近记录: |