@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
this.getWindow().setType(WindowManager.LayoutParams.TYPE_KEYGUARD);
} @Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if(keyCode == KeyEvent.KEYCODE_HOME){
状态栏加图标的操作;
}
return super.onKeyDown(keyCode, event);
}
然后怎么让Home键的功能继续有用啊
if(keyCode == KeyEvent.KEYCODE_HOME){
NotificationManager nm =
(NotificationManager)getSystemService(NOTIFICATION_SERVICE);
Notification n = new Notification();
n.icon = R.drawable.golf_ball;
n.tickerText = "TEST NOTIFICATION";
n.when = System.currentTimeMillis();
n.flags = Notification.FLAG_AUTO_CANCEL;
PendingIntent pi = PendingIntent.getActivity(this,0,new Intent(),0);
n.setLatestEventInfo(this, "GolfSystem", "GolfSystem正在后台运行", pi);
nm.notify(1, n);
return true;
}
return super.onKeyDown(keyCode, event);
}