2014年9月4日 星期四

readPhone

package com.ewallet.citygo.tool;

import android.content.Context;
import android.os.Build;
import android.telephony.TelephonyManager;
import android.util.Log;

public class HomeTool {
    private static HomeTool homeTool = null;
    public static HomeTool getInstance(){  //新增一個public method getInstance()判斷有沒有new過
         if(homeTool == null){
             homeTool = new HomeTool();
           
         }
         return homeTool;
       
    }
   
    public void readPhone(Context context){
        TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);

        //取得 IMEI 碼↓
        String IMEI = telephonyManager.getDeviceId();
        Log.d("IMEI:",IMEI);

        //取得 IMSI 碼↓
        String IMSI=telephonyManager.getSubscriberId();
        Log.d("IMSI:",IMSI);
        //取的 SIM 卡序號↓
        String SIM=telephonyManager.getSimSerialNumber();
        Log.d("SIM:",SIM);
        //取得 PhoneType↓ (NONE、GSM、CDMA、SIP)
        int PhoneType=telephonyManager.getPhoneType();
        Log.d("PhoneType:",""+PhoneType);
        //取得目前網路類型↓ (UNKNOWN、GPRS、EDGE、HSDPA、CDMA、......)
        int UNKNOWN =telephonyManager.getNetworkType();
        Log.d("UNKNOWN:",""+UNKNOWN);
        //取得國家代碼↓ (TW)
        String TW=telephonyManager.getNetworkCountryIso();
        Log.d("TW:",""+TW);

        //取得電信商名稱↓ (中華電信)
        String Operator =telephonyManager.getNetworkOperatorName();
        Log.d("Operator",""+Operator);
        // 主機版名稱
        String board = Build.BOARD;
       
        // 品牌名稱
        String brand = Build.BRAND;
       
        // CPU + ABI
        String cpu = Build.CPU_ABI;
       
        // 設備名稱
        String device = Build.DEVICE;
       
        // 版本號碼
        String display = Build.DISPLAY;
       
        // 設備識別碼
        String fingerprint = Build.FINGERPRINT;
       
        // HOST
        String host = Build.HOST;
       
        // 版本號碼
        String id = Build.ID;
       
        // 製造商
        String manufacturer = Build.MANUFACTURER;
       
        // 模組號碼
        String model = Build.MODEL;
       
        // 產品名稱
        String product = Build.PRODUCT;
       
        // 設備描述
        String tags = Build.TAGS;
       
        // 設備類別; user or eng
        String type = Build.TYPE;
       
        // USER
        String user = Build.USER;
    }
   
}

沒有留言:

張貼留言