[FREE] Device 💻 - Get device info!

nice update!

1 Like

I tested your extension and it's working :wink:

4 Likes

Thanks. I received your message already.

If you don't know, @StarredStare is my classmate.

2 Likes

This extension is now added to my website.

1 Like

I realized that this extension does not work on the App Inventor emulator.

When I added this component to the project, it gave me a huge, unreasonable runtime error, so don't test it with the eumlator.

Error from Companion: java.lang.RuntimeException: invalid syntax in eval form: :14:1: caught exception in inliner for # - java.lang.RuntimeException: no such class: com.gordonlu.device.Device gnu.bytecode.ObjectType.getReflectClass(ObjectType.java:179) gnu.bytecode.ClassType.getModifiers(ClassType.java:103) gnu.bytecode.ClassType.isInterface(ClassType.java:471) gnu.expr.InlineCalls.checkType(InlineCalls.java:56) gnu.expr.InlineCalls.visit(InlineCalls.java:49) gnu.expr.InlineCalls.visitSetExpValue(InlineCalls.java:363) gnu.expr.InlineCalls.visitSetExpValue(InlineCalls.java:28) gnu.expr.ExpVisitor.visitSetExp(ExpVisitor.java:114) gnu.expr.InlineCalls.visitSetExp(InlineCalls.java:369) gnu.expr.InlineCalls.visitSetExp(InlineCalls.java:28) gnu.expr.SetExp.visit(SetExp.java:406) gnu.expr.ExpVisitor.visit(ExpVisitor.java:55) gnu.expr.InlineCalls.visit(InlineCalls.java:46) gnu.expr.InlineCalls.visitBeginExp(InlineCalls.java:272) gnu.expr.InlineCalls.visitBeginExp(InlineCalls.java:28) gnu.expr.BeginExp.visit(BeginExp.java:156) gnu.expr.ExpVisitor.visit(ExpVisitor.java:51) gnu.expr.InlineCalls.visit(InlineCalls.java:46) gnu.expr.InlineCalls.visitBeginExp(InlineCalls.java:272) gnu.expr.InlineCalls.visitBeginExp(InlineCalls.java:28) gnu.expr.BeginExp.visit(BeginExp.java:156) gnu.expr.ExpVisitor.visit(ExpVisitor.java:51) gnu.expr.InlineCalls.visit(InlineCalls.java:46) gnu.expr.InlineCalls.visitLetExp(InlineCalls.java:317) gnu.expr.InlineCalls.visitLetExp(InlineCalls.java:28) gnu.expr.LetExp.visit(LetExp.java:207) gnu.expr.ExpVisitor.visit(ExpVisitor.java:51) gnu.expr.InlineCalls.visit(InlineCalls.java:46) gnu.expr.InlineCalls.visit(InlineCalls.java:28) gnu.expr.LambdaExp.visitChildrenOnly(LambdaExp.java:1664) gnu.expr.LambdaExp.visitChildren(LambdaExp.java:1651) gnu.expr.InlineCalls.visitScopeExp(InlineCalls.java:279) gnu.expr.InlineCalls.visitLambdaExp(InlineCalls.java:349) gnu.expr.InlineCalls.visitLambdaExp(InlineCalls.java:28) gnu.expr.LambdaExp.visit(LambdaExp.java:1640) gnu.expr.ExpVisitor.visit(ExpVisitor.java:55) gnu.expr.InlineCalls.visit(InlineCalls.java:46) gnu.expr.InlineCalls.visit(InlineCalls.java:28) gnu.expr.ExpVisitor.visitAndUpdate(ExpVisitor.java:161) gnu.expr.ExpVisitor.visitExps(ExpVisitor.java:175) gnu.expr.ApplyExp.visitArgs(ApplyExp.java:415) gnu.kawa.reflect.CompileInvoke.validateApplyInvoke(CompileInvoke.java:23) java.lang.reflect.Method.invokeNative(Native Method) java.lang.reflect.Method.invoke(Method.java:521) gnu.expr.InlineCalls.maybeInline(InlineCalls.java:467) gnu.expr.QuoteExp.validateApply(QuoteExp.java:150) gnu.expr.ReferenceExp.validateApply(ReferenceExp.java:191) gnu.kawa.functions.CompilationHelpers.validateApplyToArgs(CompilationHelpers.java:66) java.lang.reflect.Method.invokeNative(Native Method) java.lang.reflect.Method.invoke(Method.java:521) gnu.expr.InlineCalls.maybeInline(InlineCalls.java:467) gnu.expr.QuoteExp.validateApply(QuoteExp.java:150) gnu.expr.ReferenceExp.validateApply(ReferenceExp.java:191) gnu.expr.InlineCalls.visitApplyExp(InlineCalls.java:119) gnu.expr.InlineCalls.visitApplyExp(InlineCalls.java:28) gnu.expr.ApplyExp.visit(ApplyExp.java:410) gnu.expr.ExpVisitor.visit(ExpVisitor.java:55) gnu.expr.InlineCalls.visit(InlineCalls.java:46) gnu.expr.QuoteExp.validateApply(QuoteExp.java:162) gnu.expr.ReferenceExp.validateApply(ReferenceExp.java:191) gnu.kawa.functions.CompilationHelpers.validateApplyToArgs(CompilationHelpers.java:66) java.lang.reflect.Method.invokeNative(Native Method) java.lang.reflect.Method.invoke(Method.java:521) gnu.expr.InlineCalls.maybeInline(InlineCalls.java:467) gnu.expr.QuoteExp.validateApply(QuoteExp.java:150) gnu.expr.ReferenceExp.validateApply(ReferenceExp.java:191) gnu.expr.InlineCalls.visitApplyExp(InlineCalls.java:119) gnu.expr.InlineCalls.visitApplyExp(InlineCalls.java:28) gnu.expr.ApplyExp.visit(ApplyExp.java:410) gnu.expr.ExpVisitor.visit(ExpVisitor.java:51) gnu.expr.InlineCalls.visit(InlineCalls.java:46) gnu.expr.InlineCalls.visitBeginExp(InlineCalls.java:272) gnu.expr.InlineCalls.visitBeginExp(InlineCalls.java:28) gnu.expr.BeginExp.visit(BeginExp.java:156) gnu.expr.ExpVisitor.visit(ExpVisitor.java:51) gnu.expr.InlineCalls.visit(InlineCalls.java:46) gnu.expr.InlineCalls.visit(InlineCalls.java:28) gnu.expr.LambdaExp.visitChildrenOnly(LambdaExp.java:1664) gnu.expr.LambdaExp.visitChildren(LambdaExp.java:1651) gnu.expr.InlineCalls.visitScopeExp(InlineCalls.java:279) gnu.expr.InlineCalls.visitLambdaExp(InlineCalls.java:349) gnu.expr.InlineCalls.visitLambdaExp(InlineCalls.java:28) gnu.expr.ExpVisitor.visitModuleExp(ExpVisitor.java:103) gnu.expr.ModuleExp.visit(ModuleExp.java:482) gnu.expr.ExpVisitor.visit(ExpVisitor.java:51) gnu.expr.InlineCalls.visit(InlineCalls.java:46) gnu.expr.InlineCalls.inlineCalls(InlineCalls.java:33) gnu.expr.Compilation.walkModule(Compilation.java:994) gnu.expr.Compilation.process(Compilation.java:1965) gnu.expr.ModuleInfo.loadByStages(ModuleInfo.java:330) gnu.expr.ModuleExp.evalModule1(ModuleExp.java:238) gnu.expr.ModuleExp.evalModule(ModuleExp.java:198) gnu.expr.Language.eval(Language.java:943) gnu.expr.Language.eval(Language.java:883) gnu.expr.Language.eval(Language.java:865) com.google.appinventor.components.runtime.util.AppInvHTTPD.serve(AppInvHTTPD.java:190) com.google.appinventor.components.runtime.util.NanoHTTPD$HTTPSession.run(NanoHTTPD.java:489) java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1068) java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:561) java.lang.Thread.run(Thread.java:1096)

1 Like

Nice extension @Gordon_Lu

2 Likes

Maybe the emulator doesn't support this feature...?

2 Likes

It's because the emulator is very old I guess. It is just like it was last updated 9-10 years ago... Android is too old on it. Android has very updated now so it supports on the latest new android os!

1 Like

Nice extension :slight_smile:

An Alternative

[Beta] DevyInfo : Get info your device - Extensions - Kodular Community

2 Likes

That extension is so crazy - probably the extension developer put a lot of effort in it.

Version 6 Added!

I would like to thank @Taifun a lot for this update, they let me learn a lot from their extension!

Implemented from Battery Utilities from Kodular.

New blocks:

Method blocks

BatteryHealth

image

Returns the health value of the phone's battery. Can be: UNKNOWN, GOOD, OVERHEAT, DEAD, OVER_VOLTAGE, UNSPECIFIED_FAILURE, COLD.

Returns: text

BatteryPercentage

image

Returns the battery level in percentage.

Returns: int

BatteryTechnology

image

Returns the battery technology.

Returns: int

BatteryVoltage

image

Returns the current battery voltage.

Returns: int

IsBatteryPresent

image

Indicating whether a battery is present.

Returns: boolean

Property Blocks

BatteryCharging

image

Returns true if the device is charging, else false.

Returns: boolean

BatteryPlugged

image

Returns the device the phone is plugged to. Can be 'USB', 'AC', 'WIRELESS' or 'UNKNOWN'.

Returns: text

NOTE: Remember to distinguish the above blocks. They are 100% different.

4 Likes

@Gordon_Lu. THIS IS THE BEST UPDATE YET!

1 Like

Launching next version tomorrow or later, probably after my math test.

This is what it is going to be:



BTW: Have you voted yet for OS? Today is the last day!

https://community.appinventor.mit.edu/t/free-get-device-info/48411/18?u=gordon_lu

2 Likes

Voting poll closed. If you want to know some part of the code, PM me.

1 Like

Hi everyone,

I finally have some time after my test, so I'm introducing version 7. I implemented some more blocks from the Kodular components of Device Utilities, Battery Utilities and Color Utilities, and even some of my own.

Methods

BatteryPluggedSource

image

Returns the device the phone is plugged to. Can be 'USB', 'AC', 'WIRELESS' or 'UNKNOWN'.

Returns: text

Removed the old property block of BatteryPlugged.

BatteryStatus

image

Returns the current status of the phone's battery. Can be: UNKNOWN, CHARGING, DISCHARGING, NOT_CHARGING or FULL.

Returns: text

ColorConvertHexToInt

image

Convert a hex color to a integer color. The result is returned as integer. This function does not support shorthand hex values like #000. The expected parameter for hexColor is something like #FFFFFF.

Returns: int

Parameters: hexColor = text

Note: When I say a hex color, I do not include hexadecimal values. Thank you very much.

ColorConvertIntToHex

image

Convert a integer color to a hex color. The result is returned as string.

Returns: int

Parameters: intColor = number (int)

DisplayCountry

image

Returns a name for the locale's country that is appropriate for display to the user.

Returns: string

DisplayLanguage

image

Returns a name for the locale's language that is appropriate for display to the user.

Returns: text

DisplayScript

image

Returns a name for the the locale's script that is appropriate for display to the user.

Returns: text

GetLuminanceOfColor

image

Returns the relative luminance of a color. This block only supports devices above or Android 8.0.

Returns: number (float)

Parameters: color = number (long)

NumberToString

image

Converts a number to a string.

Returns: text

Parameters: number = number (int)

StringToNumber

image

Converts a string to a number.

Returns: number (int)

Parameters: string = text

Property

CpuTemperature

image

Returns the CPU temperature of the device.

*Returns: number (float)

This is an Open Source property.

How do you calculate the CPU temperature?

  1. Import these:
import java.io.BufferedReader;
import java.io.InputStreamReader;

Then use this:

    @SimpleProperty(description = "Returns the CPU temperature of the device.")
    public static float CpuTemperature () {
    Process process;
    try {
        process = Runtime.getRuntime().exec("cat sys/class/thermal/thermal_zone0/temp");
        process.waitFor();
        BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream()));
        String line = reader.readLine();
        if(line!=null) {
            float temp = Float.parseFloat(line);
            return temp / 1000.0f;
        } else {
            return 51.0f;
        }
    } catch (Exception e) {
        e.printStackTrace();
        return 0.0f;
    }
}

Feel free to copy the code and add it to your extension!

5 Likes

good/great update @Gordon_Lu!

1 Like
  1. What do these have to do with device information?
  2. NumberToString and StringToNumber can be easily done with app inventor blocks:

off-topic

The ColorConvertHexToInt and ColorConvertIntToHex are in the Kodular documentation, so I was planning to implement them in my extension. They have something to do with that - they are utility blocks, else Kodular won't add them.

There is a way to convert numbers or strings, though.

1 Like

I have made a library for getting device informations some months ago for my android studio application and is open-source here. You can look over to these codes and add some more too :))

Congratulations for the extension :cherry_blossom:

1 Like

Version 8!

Big thanks to @oseamiya for this version, I can't create this update without your code.

Methods

CurrentLatitude

image

Returns the user's current latitude.

Returns: number (double)

Note: I tested this block with the LocationSensor, and found that this block is a bit faster than that. You can use both of them in the app, but I would not suggest you because this is available with built-in blocks.

CurrentLongitude

image

Returns the user's current longitude.

Returns: number (double)

Note: I tested this block with the LocationSensor, and found that this block is a bit faster than that. You can use both of them in the app, but I would not suggest you because this is available with built-in blocks.

DisplayFontScale

image

Returns the font scale of the display.

Returns: number (float)

DisplayHeight

image

Returns the display height of the device.

Returns: number (int)

DisplayPhysicalSize

image

Returns the physical size of the device.

Returns: number (double)

DisplayWidth

image

Returns the display width of the device.

Returns: number (int)

GetCity

image

Returns the city name from the given latitude and the longitude.

Returns: string

Parameters: latitude = double, longitude = double

GetCountryName

image

Returns the name of the country from the given latitude and longitude.

Returns: string

Parameters: latitude = double, longitude = double

GetPostalCode

image

Returns the postal code from the latitude and the longitude.

Returns: string

Parameters: latitude = double, longitude = double

GetStreetAddress

image

Returns the street address from the given latitude and the longitude.

Returns: string

Parameters: latitude = double, longitude = double

IsCameraAvailable

image

Returns true if the device's camera is available, else false.

Returns: boolean

IsDarkColor

image

Returns true if the color is dark, else it returns false, means the color is light. The result is returned as boolean.

Returns: boolean

Parameters: color = number (int) / color

IsExternalMemoryAvailable

image

Checks if external memory is available.

Returns: boolean

IsFlashAvailable

image

Returns true if the device has a flashlight, else false.

Returns: boolean

Iso3Country

image

Returns a three-letter abbreviation for this locale's country. If the country matches an ISO 3166-1 alpha-2 code, the corresponding ISO 3166-1 alpha-3 uppercase code is returned. If the locale doesn't specify a country, this will be the empty string.

Returns: string

Iso3Language

image

Returns a three-letter abbreviation of this locale's language. If the language matches an ISO 639-1 two-letter code, the corresponding ISO 639-2/T three-letter lowercase code is returned. The ISO 639-2 language codes can be found on-line, see "Codes for the Representation of Names of Languages Part 2: Alpha-3 Code". If the locale specifies a three-letter language, the language is returned as is. If the locale does not specify a language the empty string is returned.

Returns: string

MemoryFree

image

Returns the available RAM on the device in Megabytes.

Returns: number (long)

MemoryTotal

image

Returns the total RAM on the device in Megabytes.

Returns: number (long)

MemoryUsed

image

Returns the used RAM on the device in Megabytes.

Returns: number (long)

NavigationBarHeight

image

Returns the height of the navigation bar of the device.

Returns: number (int)

NumberOfCameras

image

Returns the number of cameras available on the device.

Returns: number (int)

Properties

AndroidVersion

image

Returns the Android version of the phone.

Returns: string

5 Likes