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

Simple car racing android game in Sketchware

Creating a Drawing View in Sketchware

Enable Fullscreen for Youtube videos in WebView

How to enable upload from webview in Sketchware?

List of Calendar Format symbols valid in Sketchware