2014-07-27 161 views

回答

0

查看源代碼,你將需要使用 DeviceAdminReceiver http://developer.android.com/reference/android/app/admin/DeviceAdminReceiver.html

爲去功能默認的Android屏幕鎖。

用於啓動活動時,用戶解鎖屏幕註冊一個Intent.ACTION_SCREEN_ONIntent.ACTION_SCREEN_OFF爲:

添加該代碼manifast.xml註冊ScreenReceiver爲:

<receiver android:name=".ScreenReceiver"> 
<intent-filter> 
<action android:name="android.intent.action.SCREEN_OFF"/> 
<action android:name="android.intent.action.SCREEN_ON"/> 
</intent-filter> 
</receiver> 

並添加ScreenReceiver.java爲:

public class ScreenReceiver extends BroadcastReceiver { 
    @Override 
    public void onReceive(Context context, Intent intent) { 
     if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) 
     { 
      Intent intent = new Intent(); 
      intent.setClass(context, ScreenLockActivity.class); 
      startActivity(intent);   
     } 
相關問題