[FREE] Device 💻 - Get device info!

yes finally you added one of my blocks suggestions yay @Gordon_Lu!
very good excellent update!

1 Like

I'm making the AndroidVersion block open source here. I used a lot of code - I don't know if other developers used this much too. I'm looking for a simplier way to achieve this.

@SimpleProperty(description = "Returns the Android version of the phone.")

    public String AndroidVersion () {

        if (android.os.Build.VERSION.SDK_INT == 9) {

            return "2.3";

        } else if (android.os.Build.VERSION.SDK_INT == 10) {

            return "2.3.3";

        } else if (android.os.Build.VERSION.SDK_INT == 11) {

            return "3.0";

        } else if (android.os.Build.VERSION.SDK_INT == 12) {

            return "3.1";

        } else if (android.os.Build.VERSION.SDK_INT == 13) {

            return "3.2";

        } else if (android.os.Build.VERSION.SDK_INT == 14) {

            return "4.0";

        } else if (android.os.Build.VERSION.SDK_INT == 15) {

            return "4.0.3";

        } else if (android.os.Build.VERSION.SDK_INT == 16) {

            return "4.1";

        } else if (android.os.Build.VERSION.SDK_INT == 17) {

            return "4.2";

        } else if (android.os.Build.VERSION.SDK_INT == 18) {

            return "4.3";

        } else if (android.os.Build.VERSION.SDK_INT == 19) {

            return "4.4";

        } else if (android.os.Build.VERSION.SDK_INT == 20) {

            return "4.4W";

        } else if (android.os.Build.VERSION.SDK_INT == 21) {

            return "5.0";

        } else if (android.os.Build.VERSION.SDK_INT == 22) {

            return "5.1";

        } else if (android.os.Build.VERSION.SDK_INT == 23) {

            return "6.0";

        } else if (android.os.Build.VERSION.SDK_INT == 24) {

            return "7.0";

        } else if (android.os.Build.VERSION.SDK_INT == 25) {

            return "7.1";

        } else if (android.os.Build.VERSION.SDK_INT == 26) {

            return "8.0";

        } else if (android.os.Build.VERSION.SDK_INT == 27) {

            return "8.1";

        } else if (android.os.Build.VERSION.SDK_INT == 28) {

            return "9";

        } else if (android.os.Build.VERSION.SDK_INT == 29) {

            return "10";

        } else if (android.os.Build.VERSION.SDK_INT == 30) {

            return "11";

        } else if (android.os.Build.VERSION.SDK_INT == 31) {

            return "12";

        } else { 

            return "UNKNOWN";

        }

    }
2 Likes

You can use

String versionRelease = Build.VERSION.RELEASE
3 Likes

Yeah, you are 33% right, but Google's documentation said,

Do not assume that its value has any particular structure or that values of RELEASE from different releases can be somehow ordered.

So it might return 1.0, bananas or 3.4b5.

3 Likes

Version 9!

Still, big thanks to @oseamiya .

Updates:

  1. Changed all Megabytes to Bytes because I discovered a number loss during the conversion.
1 Megabyte = 1024 * 1024 Bytes

Methods

ApplicationName

image

Returns the application name from the given package name, else returns the notFound value.

Returns: text

Parameters: packageName = text, notFound = text

DisplayRefreshRate

image

Returns the refresh rate of the display in frames per second.

Returns: number (float)

DisplayRotation

image

Returns the rotation of the screen from its "natural" orientation. The returned value may be Surface.ROTATION_0 (no rotation), Surface.ROTATION_90 , Surface.ROTATION_180 , or Surface.ROTATION_270 . For example, if a device has a naturally tall screen, and the user has turned it on its side to go into a landscape orientation, the value returned here may be either Surface.ROTATION_90 or Surface.ROTATION_270 depending on the direction it was turned. The angle is the rotation of the drawn graphics on the screen, which is the opposite direction of the physical rotation of the device.

Returns: number (int)

ExternalStorageAvailable

image

Returns the available storage size in bytes.

Returns: number (long)

ExternalStorageTotal

image

Returns the total amount of external storage in bytes.

Returns: number (long)

ExternalStorageUsed

image

Returns the used amount of external storage in bytes.

Returns: number (long)

SensorAmount

image

Returns the total amount of sensors on the device.

Returns: number (int)

SensorList

image

Returns a list of all sensors on the device.

Note: I will NOT show the Do-It for this block because the Do-It is way too much. Here is an example of what result it will return:

[
{
 Sensor name="Proximity Sensor", 
 vendor="xiaomi Inc.", 
 version=1,
 type=8,
 maxRange=5.0,
 resolution=1.0,
 power=0.012,
 minDelay=200000
 }, 

{
 Sensor name="icm4x6xx Accelerometer Non-wakeup",
 vendor="TDK-Invensense",
 version=307,
 type=1,
 maxRange=156.9064,
 resolution=0.0047884034,
 power=0.24,
 minDelay=2000
 },

{
 Sensor name="ak0991x Magnetometer Non-wakeup",
 vendor="akm",
 version=146970,
 type=2,
 maxRange=4911.994,
 resolution=0.15,
 power=1.1,
 minDelay=10000
 }
]
4 Likes

@Gordon_Lu could you edit the version and new blocks in the first post?
you just put the do it images

Ok sure I will do it now.

My website is edited with the latest version, click here.

2 Likes

Thanks
The new blocks and the megabytes to bytes is changed but not the version code

should be

Version: 9

It was changed. Did you refresh the topic?

I didn't said it's not changed

just said the version code is not changed (but it changed now)

1 Like

But still I REALY like this extension! :heart: :heart:

1 Like

Version 10 AGAIN!

As usual, thanks to @oseamiya.

Special thanks to my classmates Charmaine and Hayson.

InternalMemoryAvailable

image

Returns the available internal memory in bytes.

Returns: number (long)

InternalMemoryTotal

image

Returns the total internal memory size in bytes.

Returns: number (long)

InternalMemoryUsed

image

Returns the used internal memory size in bytes.

Returns: number (long)

KernalVersion

image

Returns the Kernel version of the device.

Returns: string

3 Likes

you are updating this extension VERY fast and well! nice work!
lf you continue, this will happen:

and this will be the best extension after the Rubik's cube extension!

4 Likes

Update = Appinventor.Extensions.Updates.Device.Feedback(Feedback.CoolUpdate);

Cool Update!

1 Like

Deep cool update

But block should be 'KernelVersion' not 'KernalVersion'

1 Like

Version 11

Fixed KernelVersion typo mistake.

IsEmailAddressValid

image

Tests if the email address is valid.

Returns: boolean

Parameters: emailAddress = text

In case you're wondering, this has something to do with the user's device. When you are verifying an email from the user's device in a login app, you can use this.

3 Likes

Version 12

VersionCodeFrom

image

Returns the version code from the package name. In case an error occurs, the notFound value is returned.

Returns: number (int)

Parameters: packageName = text, notFound = text

VersionNameFrom

image

Returns the version name of an app from the package name. In case an error occurs, the notFound value is returned.

Returns: number (int)

Parameters: packageName = text, notFound = text

1 Like

the image is wrong

and there are two version 12! posts