是否有可能从任何Android对话强制要么是/否? [英] Is it possible to force either Yes/No from any android Dialog?

查看:198
本文介绍了是否有可能从任何Android对话强制要么是/否?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个意图,即
最终,询问用户是否是或否。

I have several intent, that eventually asking the user whether "Yes" or "No".

在其中,对话本身不是从我的code。我只是在执行的意图。

In which, the dialog itself is not from my code. I just executing the Intent.

我的问题很简单。

如何SUR preSS从意向显示的每个对话框,并迫使其要么是/否?

How to surpress each dialog shown from the intent and Force it to either "yes" / "no" ?

例如该code:

Intent BlueIntent  = new Intent(bluetooth.ACTION_DISCOVERY_STARTED);
        BlueIntent.putExtra(bluetooth.EXTRA_DISCOVERABLE_DURATION, 300);
        startActivity(BlueIntent);

我们都知道上述code将询问用户(通过显示是/否对话框中)给用户。
因此,如何强制选择编程要么是或否为每所示对话框?

We all know the above code will ask the user (by showing a YES / No dialog) to the user. So how to force the selection programatically either "yes" or "no" for every dialog shown?

什么想法?

推荐答案

虽然我知道这是的通常不会可以覆盖用户输入的其他活动。

Answer:

As much as I know this is normally NOT possible to override user input in another activity.

您正在打开的蓝牙设置使用意图键,让用户处理其余部分。任何应用程序不应该处理/改变的输入事件的另一个 (除非它是一个辅助服务)。所以这个失败应用程序安全性的整个概念。

You are opening the Bluetooth Settings using the Intent and let the user handle the rest. any app is not supposed to handle/alter the input events of another (Unless it is an accessibility service). So this fails the whole concept of Application security.

AccessibilityService 的情况下,S上的用户必须明确使用它们开始在辅助功能设置有特殊服务。看到文档

In case of AccessibilityServices the user must start them explicitly using the Accessibility Settings which have special services. see docs.

这是 AccessibilityService 可以拦截用户的输入和具体的事件,但我不知道如何可以用来实现你想要的。

An AccessibilityService can intercept user input and specific events but I am not sure how it can be used to achieve what you want.

[提示] 我觉得你可以直接打开蓝牙如果你有 android.permission.BLUETOOTH_ADMIN 许可。通过这个你可以避开的设置生成的默认对话框。

[TIP] I think you can open the Bluetooth directly if you have the android.permission.BLUETOOTH_ADMIN permission. by this you can avoid the default dialog generated by the settings.

希望我的回答可以帮助你。

Hope my answer helps you.

这篇关于是否有可能从任何Android对话强制要么是/否?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆