In this video it shows the code to restrict capturing the screenshots or recording the App’s layout using Android’s in-built recording functionality.
Steps to pair your device over wifi is shown in below link:
https://programmerworld.co/android/how-to-wirelessly-connect-over-wifi-physical-phone-in-android-studio-for-debugging-your-apps-code/
I hope you like this video. For any questions, suggestions or appreciation please contact us at: https://programmerworld.co/contact/ or email at: programmerworld1990@gmail.com
Complete source code and other details:
package com.programmerworld.screenshotrestriction;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.WindowManager;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE,
WindowManager.LayoutParams.FLAG_SECURE);
}
}
Alternatively, one can use below code as well:
package com.programmerworld.restrictscreenshot;
import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
getWindow().setFlags(FLAG_SECURE, FLAG_SECURE);
}
}