android 通过反射拿取imei

2019-05-07  本文已影响0人  小子巅
public static String[]getInvokeImei(Activity context) {

TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

    Class clazz = telephonyManager.getClass();

    Method getImei =null;

    String[] imei=new String[2];

    try {

    getImei = clazz.getDeclaredMethod(StringCf.GI, int.class);

    imei[0]=(String) getImei.invoke(telephonyManager, 0);

    imei[1]=(String) getImei.invoke(telephonyManager, 1);

        //Log.e(TAG, "IMEI1 : " + getImei.invoke(telephonyManager, 0) + "IMEI2:" + getImei.invoke(telephonyManager, 1)); //卡1

    }catch (Exception e) {

    e.printStackTrace();

    }

    return imei;

        }
上一篇下一篇

猜你喜欢

热点阅读