List of usage examples for android.security KeyChain choosePrivateKeyAlias
public static void choosePrivateKeyAlias(@NonNull Activity activity, @NonNull KeyChainAliasCallback response, @Nullable @KeyProperties.KeyAlgorithmEnum String[] keyTypes, @Nullable Principal[] issuers, @Nullable Uri uri, @Nullable String alias)
From source file:com.afwsamples.testdpc.policy.PolicyManagementFragment.java
/** * Selects a private/public key pair to uninstall, using the system dialog to choose * an alias.//from www. java2 s . c o m * * Once the alias is chosen and deleted, a {@link Toast} shows status- success or failure. */ @TargetApi(Build.VERSION_CODES.N) private void choosePrivateKeyForRemoval() { KeyChain.choosePrivateKeyAlias(getActivity(), new KeyChainAliasCallback() { @Override public void alias(String alias) { if (alias == null) { // No value was chosen. return; } final boolean removed = mDevicePolicyManager.removeKeyPair(mAdminComponentName, alias); getActivity().runOnUiThread(new Runnable() { @Override public void run() { if (removed) { showToast(R.string.remove_keypair_successfully); } else { showToast(R.string.remove_keypair_fail); } } }); } }, /* keyTypes[] */ null, /* issuers[] */ null, /* uri */ null, /* alias */ null); }