• RSS
  • Delicious
  • Digg
  • Facebook
  • Twitter
  • Linkedin
Posted by Jack - - 0 comments


GET SCREEN SIZE 

SOURCE CODE is

package com.ScreenSizeExample;

import android.app.Activity;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.widget.Toast;

public class ScreenSizeExample extends Activity
{
                public void onCreate(Bundle savedInstanceState)
{
 super.onCreate(savedInstanceState);
                                setContentView(R.layout.main);
       
                                 int height,width;

DisplayMetrics displaymetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
       
                                height = displaymetrics.heightPixels;
                                width = displaymetrics.widthPixels;
       
                                Toast msg = Toast.makeText(ScreenSizeExample.this,
                                                "HEIGHT : "+height+"\nWIDTH : "+width, Toast.LENGTH_LONG);
                                msg.show();
}
}




The OUTPUT will be

https://lh3.googleusercontent.com/_xnrF0YSUul8/TXXlCddUAUI/AAAAAAAAAEc/212yjg8T0GQ/screen_size.png

Leave a Reply