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.


Comments

Popular posts from this blog

Android O New Features Overview

This post assumes, you are an experienced developer who wants to get started with the latest version of Android. Android O is not a huge update to the OS and application framework like M but it still has many useful features for both developer and an user. Android O has focus on below areas. Notification redesigned Picture-in-Picture(PIP)  Visual adaption for different devices  Battery life improved Setting app reorganized Notification redesigned: Android O notification changes includes more easy and manageable way to manager your notification behavior and settings. It includes: Notification Channel: Notification channel allows you to create user customizable channel for each type of notification you wanna display. A single application can have multiple channel, a separate channel for each type of notification you wanna display. Having said this, you can create s separate channel for audio & image notification. User can disable specific notification channe...

Overview of how to develop native code with Android NDK:

  Create a jni directory and place native source code under $PROJECT/jni/... Create Android.mk directory and place it under $PROJECT/jni/... to describe source code to the NDK build system. Create Application.mk and place it under $PROJECT/jni/...to describe project in more details to the NDK build system.It is an optional. Finally need to build native source code by running '$NDK/ndk-build' from project directory or it's sub-directory. Android.mk An Android.mk file is a small build script that we write to describe sources to the NDK build system. It's syntax is like this... LOCAL_PATH:=$(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE:=hello-jni LOCAL_SRC_FILES:=hello-jni.c include $(BUILD_SHARED_LIBRARY) NDK groups your sources into "modules", where each module can be one of the following: Static library Shared library We can write several module in a single 'Android.mk' or can write seve...

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:layo...