當前位置: 首頁>>代碼示例>>Java>>正文


Java KeyguardManager.createConfirmDeviceCredentialIntent方法代碼示例

本文整理匯總了Java中android.app.KeyguardManager.createConfirmDeviceCredentialIntent方法的典型用法代碼示例。如果您正苦於以下問題:Java KeyguardManager.createConfirmDeviceCredentialIntent方法的具體用法?Java KeyguardManager.createConfirmDeviceCredentialIntent怎麽用?Java KeyguardManager.createConfirmDeviceCredentialIntent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.app.KeyguardManager的用法示例。


在下文中一共展示了KeyguardManager.createConfirmDeviceCredentialIntent方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: requireAuthentication

import android.app.KeyguardManager; //導入方法依賴的package包/類
/**
 * Require the user to authenticate using the configured LockScreen before accessing the credentials.
 * This feature is disabled by default and will only work if the device is running on Android version 21 or up and if the user
 * has configured a secure LockScreen (PIN, Pattern, Password or Fingerprint).
 * <p>
 * The activity passed as first argument here must override the {@link Activity#onActivityResult(int, int, Intent)} method and
 * call {@link SecureCredentialsManager#checkAuthenticationResult(int, int)} with the received parameters.
 *
 * @param activity    a valid activity context. Will be used in the authentication request to launch a LockScreen intent.
 * @param requestCode the request code to use in the authentication request. Must be a value between 1 and 255.
 * @param title       the text to use as title in the authentication screen. Passing null will result in using the OS's default value.
 * @param description the text to use as description in the authentication screen. On some Android versions it might not be shown. Passing null will result in using the OS's default value.
 * @return whether this device supports requiring authentication or not. This result can be ignored safely.
 */
public boolean requireAuthentication(@NonNull Activity activity, @IntRange(from = 1, to = 255) int requestCode, @Nullable String title, @Nullable String description) {
    if (requestCode < 1 || requestCode > 255) {
        throw new IllegalArgumentException("Request code must a value between 1 and 255.");
    }
    KeyguardManager kManager = (KeyguardManager) activity.getSystemService(Context.KEYGUARD_SERVICE);
    this.authIntent = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP ? kManager.createConfirmDeviceCredentialIntent(title, description) : null;
    this.authenticateBeforeDecrypt = ((Build.VERSION.SDK_INT >= Build.VERSION_CODES.M && kManager.isDeviceSecure())
            || (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && kManager.isKeyguardSecure()))
            && authIntent != null;
    if (authenticateBeforeDecrypt) {
        this.activity = activity;
        this.authenticationRequestCode = requestCode;
    }
    return authenticateBeforeDecrypt;
}
 
開發者ID:auth0,項目名稱:Auth0.Android,代碼行數:30,代碼來源:SecureCredentialsManager.java

示例2: showAuthScreen

import android.app.KeyguardManager; //導入方法依賴的package包/類
void showAuthScreen() {
  KeyguardManager keyguardManager = (KeyguardManager) getSystemService(
      Context.KEYGUARD_SERVICE);

  if (!keyguardManager.isKeyguardSecure()) {
    basicConfigFragment.unlockAppIDandSecret();
    return;
  }

  Intent intent = keyguardManager
      .createConfirmDeviceCredentialIntent(getString(R.string.unlock_auth_title),
          getString(R.string.unlock_auth_explain));

  if (intent != null) {
    startActivityForResult(intent, 1);
  }
}
 
開發者ID:tkrworks,項目名稱:JinsMemeBRIDGE-Android,代碼行數:18,代碼來源:MainActivity.java

示例3: showAuthenticationScreen

import android.app.KeyguardManager; //導入方法依賴的package包/類
public static void showAuthenticationScreen(Context context, int requestCode) {
	// Create the Confirm Credentials screen. You can customize the title and description. Or
	// we will provide a generic one for you if you leave it null
	Log.e(TAG, "showAuthenticationScreen: ");
	if (context instanceof Activity) {
		Activity app = (Activity) context;
		KeyguardManager mKeyguardManager = (KeyguardManager) app.getSystemService(Context.KEYGUARD_SERVICE);
		if (mKeyguardManager == null) {
			return;
		}
		Intent intent = mKeyguardManager
				.createConfirmDeviceCredentialIntent(
						context.getString(R.string.unlock_screen_title_android),
						context.getString(R.string.unlock_screen_prompt_android));
		if (intent != null) {
			app.startActivityForResult(intent, requestCode);
		} else {
			Log.e(TAG, "showAuthenticationScreen: failed to create intent for auth");
			app.finish();
		}
	} else {
		Log.e(TAG, "showAuthenticationScreen: context is not activity!");
	}
}
 
開發者ID:TrustWallet,項目名稱:trust-wallet-android,代碼行數:25,代碼來源:KS.java

示例4: showAuthenticationScreen

import android.app.KeyguardManager; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.M)
private void showAuthenticationScreen(int requestCode) {
    KeyguardManager keyguardManager = getSystemService(KeyguardManager.class);
    Intent intent = keyguardManager.createConfirmDeviceCredentialIntent(getString(R.string.please_login_title), getString(R.string.please_login_message));
    if (intent != null) {
        startActivityForResult(intent, requestCode);
    }
}
 
開發者ID:BottleRocketStudios,項目名稱:Android-Vault,代碼行數:9,代碼來源:KeychainAuthenticatedActivity.java


注:本文中的android.app.KeyguardManager.createConfirmDeviceCredentialIntent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。