App Inventor and Java


How to get the Device ID within App Inventor calling a Java app

Note: with the extension feature, this workaround is now obsolete. Thank you MIT!
Now you can use my Telephony Manager Extension together with the DeviceId method instead.

Unfortunately it is currently not possible to get a unique device ID from within App Inventor.

I now prepared a small Java app you can call with the Activity Starter from App Inventor to get the Android ID as an unique 64-bit hex string following this stackoverflow answer. Thank you Anthony.

         import android.provider.Settings.Secure;
         private String android_id = Secure.getString(getContext().getContentResolver(), Secure.ANDROID_ID);
      


Note: It's known to be null sometimes, it's documented as "can change upon factory reset". Use at your own risk, and it can be easily changed on a rooted phone.

doesn't need any permissions. You also can call directly (without App Inventor) and it will show the ID in a notifier.

You probably also might be interested in the example How to get some Device specific info with App Inventor

and How to get the Phone Number of the Device with App Inventor .

For questions about App Inventor,
please ask in the App Inventor community.Thank you.

App Inventor Blocks and Screenshot

Download


Developing and maintaining snippets, tutorials and extensions for App Inventor takes a lot of time.
I hope it saved some of your time. If yes, then you might consider to donate a small amount!

Donation amount:

or donate some mBTC to Bitcoin Address:
1Jd8kXLHu2Vkuhi15TWHiQm4uE9AGPYxi8
Bitcoin

Thank you! Taifun
 

Download idtest.aia (the App Inventor test app)
Download Id.apk (the Java app )

Back to top of page ...

Creative Commons License
This work by Pura Vida Apps is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License
with attribution (name=Pura Vida Apps and link to the source site) required.


Home | Snippets | Tutorials | Extensions | Links | Search | Privacy Policy | Contact