Search code examples
androidsecuritytapmalware

android tap jacking, how to prevent it


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.


Solution

  • 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