Skip to main content

Get device name,IMEI no,screen width,height and mobile no in Android

Hi friends,Today I'm going post about how to Get device name,IMEI no,screen width,height and mobile no.Few days ago I need to use this all in my recent project but could not seen any tutorial which explains about this all.So have look on code part it's pretty easy.Android provides us API for this all.
Code:
public class Utility {
    int sh, sw;
    Context context;
    DisplayMetrics metrics;

    public AdParameters(Context context) {

        // TODO Auto-generated constructor stub
        this.context = context;
        metrics = context.getResources().getDisplayMetrics();
    }

    public String getDeviceName() {

        return android.os.Build.MODEL;
    }

    public String getIMEI() {

        // TODO Auto-generated method stub
        TelephonyManager telephonyManager = (TelephonyManager) context
                .getSystemService(Context.TELEPHONY_SERVICE);
        return telephonyManager.getDeviceId();
        // return (Secure.getString(context.getContentResolver(),
        // Secure.ANDROID_ID));
    }

    public int getSw() {

        // TODO Auto-generated method stub
        return metrics.widthPixels;
    }

    public int getSh() {

        return metrics.heightPixels;
    }

    public String getMobielNo() {

        // TODO Auto-generated method stub
        TelephonyManager tm = (TelephonyManager) context
                .getSystemService(context.TELEPHONY_SERVICE);
        return tm.getLine1Number();

    }


}

Now you need to create an object of this class and then call appropriate method according to your requirement.


Popular posts from this blog

Display video from specific folder with rounded shape thumbnail

Hi friends ,This is complete post, about how to display video form specific folder and display it with rounded shape and play it on click event. For Rounded shape I have used custom ImageView.
Now have a look on code part.
main.xml
<?xml version="1.0" encoding="utf-8"?>
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/gridView1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:columnWidth="100dp"
    android:gravity="center"
    android:numColumns="auto_fit"
    android:stretchMode="columnWidth" >



</GridView>
gridlayout.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="verti…

Custom Volley-Gson request implementation

This page covers Volley-Gson integration and also Volley custom Request. We assume that, you are familiar with Volley and Gson.

Volley has some inbuilt request which you can use, if your response is a String, Image, or JSON, in that case, you don't need to implement a custom Request.  To use Gson with Volley, we need to implement a custom request.
To make a custom request, you need to perform following operation.
Extend Request<T> class, where T is the type of parsed response or expected response. Implement the abstract methods parseNetworkResponse() and deliverResponse().  parseNetworkResponse:  A response contains parse response of a given type i.e Gson.

@Override
    protected Response<T> parseNetworkResponse(NetworkResponse response) {
        try {
            String json = new String(
                    response.data, HttpHeaderParser.parseCharset(response.headers));
            if (BuildConfig.IS_DEBUG)
                Log.d(TAG, "Response :: " + …

Custom Android SeekBar Developement

Before starting coding for Custom SeekBar,You must have good concept of following topics. 1.Layer List 2.Animation List 3.Selector Layer List:A LayerDrawableis a drawable object that manages an array of other drawables. Each drawable in the list is drawn in the order of the list—the last drawable in the list is drawn on top.
<layer-listxmlns:android="http://schemas.android.com/apk/res/android"> <item android:id="@android:id/background" android:drawable="@drawable/seekbar_total"/> <itemandroid:id="@android:id/secondaryProgress"> <clipandroid:drawable="@drawable/seekbar_buffer"/> </item> <itemandroid:id="@android:id/progress"> <clipandroid:drawable="@drawable/seekbar_played"/> </item> </layer-list> Animation List:A AnimationDrawable is a drawable object that is used to create frame-by-frame animation.It's oneshotelement should be true if u want loop animation otherwise false.
&…