Android IMEI Get getIMEI(Context context)

Here you can find the source of getIMEI(Context context)

Description

Get Device IMEI

Declaration

public static String getIMEI(Context context) 

Method Source Code

//package com.java2s;
import android.content.Context;

import android.provider.Settings.Secure;
import android.telephony.TelephonyManager;
import android.text.TextUtils;

public class Main {
    /**//w w  w.j a v a2  s  . c  o m
     * Get Device IMEI
     * 
     * @author Sean Zheng
     * @CreateDate 2013-5-13
     */
    public static String getIMEI(Context context) {
        String imei = "";
        TelephonyManager telephonyManager = (TelephonyManager) context
                .getSystemService(Context.TELEPHONY_SERVICE);
        if (telephonyManager != null) {
            imei = telephonyManager.getDeviceId();
            if (TextUtils.isEmpty(imei)) {
                imei = Secure.getString(context.getContentResolver(),
                        Secure.ANDROID_ID);
            }
        }
        return imei;
    }
}

Related

  1. getIMEI(Context context)
  2. getIMEI(Context context)
  3. getIMEI(Context context)
  4. showInputMethodPicker(Context context)
  5. showInputMethodSettingsPage(Context context)