2010-10-31 71 views
3

我正在編寫一個應用程序,它應該使用密碼進行保護。而不是建立一個新的,是否有可能從不同模式的應用程序使用Android的模式鎖定屏幕?重複使用Android鎖定模式

+1

[檢查此鎖定模式庫。](http://androidcustomviews.com/portfolio/android-lock-pattern/) – 2013-08-08 09:27:25

回答

-1

首先,您必須通過手動進入設置來設置模式鎖定。 然後你可以使用下面的代碼接收事件。 `

import android.app.admin.DeviceAdminReceiver; 
import android.content.Context; 
import android.content.Intent; 
import android.util.Log; 
import android.widget.Toast; 


public class DemoDeviceAdminReceiver extends DeviceAdminReceiver { 
     static final String TAG = "DemoDeviceAdminReceiver"; 

     /** Called when this application is approved to be a device administrator. */ 
     @Override 
     public void onEnabled(Context context, Intent intent) { 
       super.onEnabled(context, intent); 
       Toast.makeText(context, R.string.device_admin_enabled, 
           Toast.LENGTH_LONG).show(); 
       Log.d(TAG, "onEnabled"); 
     } 

     /** Called when this application is no longer the device administrator. */ 
     @Override 
     public void onDisabled(Context context, Intent intent) { 
       super.onDisabled(context, intent); 
       Toast.makeText(context, R.string.device_admin_disabled, 
           Toast.LENGTH_LONG).show(); 
       Log.d(TAG, "onDisabled"); 
     } 

     @Override 
     public void onPasswordChanged(Context context, Intent intent) { 
       super.onPasswordChanged(context, intent); 
       Log.d(TAG, "onPasswordChanged"); 
     } 

     @Override 
     public void onPasswordFailed(Context context, Intent intent) { 
       super.onPasswordFailed(context, intent); 
       Log.d(TAG, "onPasswordFailed"); 
     } 

     @Override 
     public void onPasswordSucceeded(Context context, Intent intent) { 
       super.onPasswordSucceeded(context, intent); 
       Log.d(TAG, "onPasswordSucceeded"); 
     } 



} 

爲了完全理解,請閱讀此。 Complete Code And Explaination

+1

而不是僅僅提供一個鏈接,[這將是更可取的](http:// meta .stackoverflow.com/a/8259)在這裏包含答案的基本部分,並提供鏈接以供其他參考。如果你不能完成這個任務,你應該考慮簡單地[留下評論](http://stackoverflow.com/privileges/comment)而不是發佈答案。 – Dukeling 2014-05-08 20:00:59

+0

對不起,因爲有很多代碼和解釋,所以我給你介紹了一些鏈接。嘗試以上,並告訴我,如果你需要任何幫助 – 2014-05-08 21:24:18