public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // disable activity enableActivity(false) } private void enableActivity(Boolean isEnabled) { if (!isEnabled) { getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE, WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE); } else { getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE); } }}
NOTE: Alternatively, you can show an overlay transparent dialog to achieve the same result with some UI hint (black opaque overlay with icon/progressbar).