Android Code Snippets

Disable screenshot

getWindow().setFlags(WindowManager.LayoutParams.FLAG_SECURE, WindowManager.LayoutParams.FLAG_SECURE);


Hide suggestions from the soft keyboard on EditText view

EditText.setInputType(InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);


Hide soft keyboard on Button Click

android.view.inputmethod.InputMethodManager imm = (android.view.inputmethod.InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);


Hide WebView scrollbar

webview1.setVerticalScrollBarEnabled(false);

webview1.setHorizontalScrollBarEnabled(false);


Get Screen Height

Point sPoint = new Point();

WindowManager wm = (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE);

wm.getDefaultDisplay().getSize(sPoint);

int screenHeight = sPoint.y;


Get Screen Width

Point sPoint = new Point();

WindowManager wm = (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE);

wm.getDefaultDisplay().getSize(sPoint);

int screenWidth = sPoint.x;




Comments

  1. Thanks for sharing this great info with us . I really appreciate the effort you put in this post it really helped me in my mobile app development project and I'm looking forward to to see some more posts like this in future from you .

    ReplyDelete

Post a Comment

Popular posts from this blog

Create Music Player app in Sketchware

A Flash Light App in Sketchware

Simple car racing android game in Sketchware

Firebase auth in Sketchware for Login Activity

In Sketchware: How to create a calculator for any simple formula?