Android Open Source - androiddevice.info Display Property






From Project

Back to project page androiddevice.info.

License

The source code is released under:

GNU General Public License

If you think the Android project androiddevice.info listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package info.androiddevice.deviceinventory.info;
/*w w w.ja  v a2  s  . com*/
import android.app.ActivityManager;
import android.content.Context;
import android.content.pm.ConfigurationInfo;
import android.graphics.Point;
import android.os.Build;
import android.util.DisplayMetrics;
import android.view.Display;
import android.view.WindowManager;

import org.json.JSONException;
import org.json.JSONObject;

import info.androiddevice.deviceinventory.Application;

public class DisplayProperty implements Property {
    @Override
    public Object getProperty() {
        JSONObject jsonObject = new JSONObject();

        ActivityManager activityManager = (ActivityManager) Application.getContext().getSystemService(Context.ACTIVITY_SERVICE);
        ConfigurationInfo configurationInfo = activityManager.getDeviceConfigurationInfo();
        try {
            jsonObject.put("GlEsVersion", configurationInfo.getGlEsVersion());
        } catch (JSONException e) {
            try {
                jsonObject.put("GlEsVersion", JSONObject.NULL);
            } catch (JSONException e1) {}
        }

        if(Build.VERSION.SDK_INT < 17) {
            DisplayMetrics displayMetrics = Application.getContext().getResources().getDisplayMetrics();
            try {
                jsonObject.put("x", Integer.valueOf(displayMetrics.widthPixels));
                jsonObject.put("y", Integer.valueOf(displayMetrics.heightPixels));
                jsonObject.put("name", "");
            } catch (JSONException e) {
            }
        } else {
            Point screenSize = new Point();
            WindowManager windowManager = (WindowManager) Application.getContext().getSystemService(Context.WINDOW_SERVICE);
            Display display = windowManager.getDefaultDisplay();
            display.getRealSize(screenSize);
            try {
                jsonObject.put("x", screenSize.x);
                jsonObject.put("y", screenSize.y);
                jsonObject.put("name", display.getName());
            } catch (JSONException e) {
            }
        }
        return jsonObject;
    }

    @Override
    public String getName() {
        return "display";
    }
}




Java Source Code List

android.system.ErrnoException.java
android.system.Os.java
android.system.StructStat.java
info.androiddevice.deviceinventory.Application.java
info.androiddevice.deviceinventory.DeviceInformation.java
info.androiddevice.deviceinventory.Error.java
info.androiddevice.deviceinventory.info.CpuinfoProperty.java
info.androiddevice.deviceinventory.info.DirProperty.java
info.androiddevice.deviceinventory.info.DisplayProperty.java
info.androiddevice.deviceinventory.info.EnvironmentProperty.java
info.androiddevice.deviceinventory.info.FeaturesProperty.java
info.androiddevice.deviceinventory.info.FileProperty.java
info.androiddevice.deviceinventory.info.GetPropProperty.java
info.androiddevice.deviceinventory.info.JavaSystemProperty.java
info.androiddevice.deviceinventory.info.MeminfoProperty.java
info.androiddevice.deviceinventory.info.MountsProperty.java
info.androiddevice.deviceinventory.info.NameProperty.java
info.androiddevice.deviceinventory.info.OtacertsProperty.java
info.androiddevice.deviceinventory.info.PackageSigProperty.java
info.androiddevice.deviceinventory.info.Property.java
info.androiddevice.deviceinventory.info.SharedLibraryNamesProperty.java
info.androiddevice.deviceinventory.info.UsbProperty.java
info.androiddevice.deviceinventory.info.Utils.java
info.androiddevice.deviceinventory.info.VersionProperty.java
info.androiddevice.deviceinventory.submission.DeviceInformationListAdapter.java
info.androiddevice.deviceinventory.submission.MainActivity.java
libcore.io.ErrnoException.java
libcore.io.Libcore.java
libcore.io.Os.java
libcore.io.StructStat.java
name.unused.android.utils.systemproperties.SystemProperty.java
name.unused.android.utils.systemproperties.exception.NoSuchPropertyException.java