Resolution tester-Step by step Android (1)

Source: Internet
Author: User

The current mobile phone store on the resolution of the label is very careless, customers often say that the business of the hardware configuration does not recognize the ability. So my app is a good solution to the phone resolution of the recognition.

First open the control and use the intent class to jump to another activity

Button button= (button) Findviewbyid (R.id.button1);
Button.setonclicklistener (New Button.onclicklistener () {
public void OnClick (View v)
{
Intent Intent =new Intent ();
Intent.setclass (Mainactivity.this, Secondactivity.class);
StartActivity (Intent);
MainActivity.this.finish ();
}

Second, in another class to create the Displaymetrics class, you can get the phone resolution directly.


Displaymetrics dm=new displaymetrics ();

Getwindowmanager (). Getdefaultdisplay (). Getmetrics (DM);

String str= "Current phone screen resolution is:" +dm.widthpixels+ "*" +dm.heightpixels;
TextView textview= (TextView) Findviewbyid (R.ID.TEXTVIEW2);
Textview.settext (str);

Resolution tester-Step by step Android (1)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.