0
我有我已經插入到我的onCreate方法下面的代碼,但它似乎工作。 我希望它在屏幕熄滅/電池按鈕按下時啓動其他活動。Android - 廣播接收器屏幕關閉意圖,不工作....?
CODE:
protected void onStartCommand() {
// TODO Auto-generated method stub
super.onStart();
ScreenReceiver();
}
public class ScreenReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) {
lock.reenableKeyguard();
Intent s = new Intent(Activity1.this , Activity2.class);
startActivity(s);
}
else if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
lock.disableKeyguard();
}
}
}
任何幫助將是非常讚賞?
而且不要忘記,在我的情況在適當的時候 –
示例代碼釋放激活鎖定? – David