Getting Device Info From MSI Android Devices

Pietro Francesco Maggi -
2 MIN READ
8

The good old ways!

On Symbol/MSI Windows Mobile devices, we where providing some APIs in the EMDK to get additional informations. Looking into the Resource Coordinator is possible to find APIs like:

  • RCM_GetESN() - retrieves the device electronic serial number
  • RCM_GetUniqueUnitId() - retrieves the unique unit identification number
  • RCM_GetVersion() - retrieves version information
  • etc…

…and we don't have anything like this in the Android EMDK. WHY?

Simply because the functionality is already included in the standard Android SDK.

Let's see how to get this is data on an MSI device with the Android OS.

The fabulous new way!

You can find the completed project in this repository on my github account, I'm using Windows 7 and Eclipse+ADT, but you can follow these steps with Android Studio quite nicely.

Create a new Project

Create a new Android project, nothing fancy here, it's just a standard app with a single Blank Activity. You can follow these images as a guideline. Your interface may vary as Google updates the Android wizard quite often.

create_project_01.jpg

create_project_02.jpg

create_project_03.jpg

create_project_04.jpg

create_project_05.jpg

Then we can do some housekeeping deleting the unnecessary main.xml menu resource:

delete_menu.jpg

We can then start the two main changes: - Setting up the Activity Layout - Updating the Activity onCreate method to retrieve the device data

activity_layout.jpg

Here's the code:

                                   

 

This together with the string.xml containing the referenced string:

      Get Device Info     Device ESN:     Build Number:     Device:   

 

Then the simple Activity java code to collect the information is:

package com.pietromaggi.sample.getdeviceinfo; import android.os.Build; import android.support.v7.app.ActionBarActivity; import android.os.Bundle; import android.widget.TextView; public class MainActivity extends ActionBarActivity {     TextView DeviceNameTextView;     TextView ESNTextView;     TextView BuildNumberTextView;     @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_main);         DeviceNameTextView = (TextView)findViewById(R.id.device_type);         DeviceNameTextView.setText(Build.DEVICE);         ESNTextView = (TextView)findViewById(R.id.device_esn);         ESNTextView.setText(Build.SERIAL);         BuildNumberTextView = (TextView)findViewById(R.id.build_number);         BuildNumberTextView.setText(Build.ID);     } }  

 

Where's the tricks?

There's really no trick, Android SDK provide this information, and more using these constants:

Obviously, it's the OEM building the device that put together the plumbing to link the correct information. Your mileage may vary on different devices.

Running this application on an ET1 with Jelly Bean you get:

screen_ET1.png

Running this application on an MC40 with Jelly Bean you get:

screen_MC40.png

While the TC55 is always a bit different :-)

screen_TC55JB.png

Hope you may find this useful. Send me an email if you'd like to see any particular topic on this blog.

 

Reprinted from my personal blog

profile

Pietro Francesco Maggi

Please Register or Login to post a reply

Replies