以编程方式输入密码

时间:2018-01-30 12:00:19

标签: android android-studio

我想在Android Studio中开发的应用程序中以编程方式在android上输入密码。我一直在环顾四周,用我见过的任何方法都找不到成功。无效的示例密码是#4636#

我尝试了Programmatically enter secret code like *#*#4636#*#* on Android中提出的几个答案但没有取得多大成功。

当我尝试以下操作时,它只会将数字输入拨号器,但秘密菜单无法打开。

String ussdCode = "*" +Uri.encode ("#")+"*"+Uri.encode ("#")+ "4636" + Uri.encode ("#")+"*"+Uri.encode ("#")+"*";
startActivity (new Intent ("android.intent.action.DIAL", Uri.parse ("tel:" + ussdCode)));

以下只是让应用程序崩溃

 sendBroadcast(new Intent("android.provider"));
 sendBroadcast(new Intent("android.provider.Telephony.SECRET_CODE", Uri.parse("android_secret_code://4636")));

这也会导致应用崩溃

String secretCode = "4636";
String action = "android.provider.Telephony.SECRET_CODE"; 
Uri uri = Uri.parse("android_secret_code://" + secretCode);
Intent intent = new Intent(action, uri);
sendBroadcast(intent);

这只拨打*而不是其他

Intent dialIntent = new Intent(Intent.ACTION_DIAL);
dialIntent.setData(Uri.parse("tel: *#*#4636#*#*"));
startActivity(dialIntent);

我将如何完成此任务?我正在使用Android 7.0+。

编辑:这与上述问题不同,因为5年前针对上述问题的修复工作不再适用。

1 个答案:

答案 0 :(得分:0)

试试这个:

    Intent intent = new Intent(Intent.ACTION_MAIN);
    intent.setClassName("com.android.settings", "com.android.settings.TestingSettings");
    startActivity(intent );
相关问题