android tap jacking, how to prevent it

人走茶凉 提交于 2019-12-03 13:58:37

问题


Trying to avoid my views touches receiving feedback from overlays ....

Here is an example of a hack someone could do on Android to allow the user to unintentionally press a system button property or even enter in credentials to do something completely different then the initial intention:

http://www.youtube.com/watch?v=gCLU7YUXUAY

I would like confirmation that setting the property

android:filterTouchesWhenObscured="true"

in my xml view would hinder this from happening across devices as im intending to make a secure app.


回答1:


public class MyActivity extends Activity {
    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        final Button myButton = (Button)findViewById(R.id.button_id);
        myButton.setFilterTouchesWhenObscured(true);
        myButton.setOnClickListener(new View.OnClickListener() {
            // Perform action on click
            public void onClick(View v) {

            }
        }
    }
}

write this code for critical buttons



来源:https://stackoverflow.com/questions/22179773/android-tap-jacking-how-to-prevent-it

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!