在EditText上键入时防止android保存和检索密码 [英] Prevent android from saving and retrieving passwords when typing on EditText

查看:283
本文介绍了在EditText上键入时防止android保存和检索密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何防止这种情况的发生,多个用户将在同一设备上使用该应用程序,但我不希望所有人都可以访问某些地方

How can I prevent this from happening, multiple users are going to use the app on the same device and I do not want all of them having access to some places

推荐答案

您只需将一个属性添加到您的editText视图中

You simply just add one property to your editText view

android:inputType="textPassword|textNoSuggestions"

您就完成了.

如果它对您不起作用,则有另一种替代解决方案.您可以通过编程方式关闭自动填充功能.

if it is not working for you there is another alternative solution. You can turn off autofill programmatically.

您可以尝试这样做.

public class BaseActivity extends AppCompatActivity {

     @Override
        public void onCreate(Bundle savedInstanceState) {
           super.onCreate(savedInstanceState);
           disableAutoFill();
        }

        @TargetApi(Build.VERSION_CODES.O)
        private void disableAutoFill() { 
            getWindow().getDecorView().setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS);
        }
    }

这篇关于在EditText上键入时防止android保存和检索密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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