本文整理汇总了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;
}
示例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);
}
}
示例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!");
}
}
示例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);
}
}