android tap jacking, how to prevent it

2020-05-29 17: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条回答
Animai°情兽
2楼-- · 2020-05-29 18:25
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

查看更多
登录 后发表回答