2011-05-15 147 views

回答

1

让您的应用听我们的ACTION_SCREEN_OFF广播。更多信息here

public class ScreenReceiver extends BroadcastReceiver {  

     @Override 
     public void onReceive(Context context, Intent intent) { 
      if (intent.getAction().equals(Intent.ACTION_SCREEN_OFF)) { 
       //screen locked     
      } else if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) { 
       //screen unlocked 
      } 
     } 

} 

您可能还需要接受当用户通过对ACTION_USER_PRESENT广播注册并获得过去的键盘锁的信息。

+0

不工作的原因是http://developer.android.com/reference/android/content/Intent.html#ACTION_SCREEN_ON只是看到那里是受保护的意图只能通过系统发送。如果您有其他选择,请发布 – 2011-11-25 08:02:19

相关问题