日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

[转] android获取手机信息大全

發布時間:2024/1/17 编程问答 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 [转] android获取手机信息大全 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

原文鏈接:http://blog.csdn.net/hytfly/article/details/8552483

IMEI號,IESI號,手機型號:

?

  • private?void?getInfo()?{????
  • ?????????????TelephonyManager?mTm?=?(TelephonyManager)?getSystemService(TELEPHONY_SERVICE);????
  • ?????????????String?imei?=?mTm.getDeviceId();????
  • ?????????????String?imsi?=?mTm.getSubscriberId();????
  • ?????????????String?mtype?=?android.os.Build.MODEL;?//?手機型號????
  • ?????????????String?numer?=?mTm.getLine1Number();?//?手機號碼,有的可得,有的不可得????
  • ?????????}??
  • ?

    ?

    手機型號 Build.MODEL

    StringMODELThe end-user-visible name for the end product.

    sdk版本 Build.VERSION.SDK

    StringSDKThis constant is deprecated. Use?SDK_INT?to easily get this as an integer.

    及frimware版本號(系統版本號)?Build.VERSION.RELEASE

    StringRELEASEThe user-visible version string.

    ?

    ?

    事實上,Build能向我們提供包括 硬件廠商,硬件編號,序列號等很多信息 調用方法也都同上,很簡單。

    ?

    ?

    ?

    StringBOARDThe name of the underlying board, like "goldfish".
    StringBOOTLOADERThe system bootloader version number.
    StringBRANDThe brand (e.g., carrier) the software is customized for, if any.
    StringCPU_ABIThe name of the instruction set (CPU type + ABI convention) of native code.
    StringCPU_ABI2The name of the second instruction set (CPU type + ABI convention) of native code.
    StringDEVICEThe name of the industrial design.
    StringDISPLAYA build ID string meant for displaying to the user
    StringFINGERPRINTA string that uniquely identifies this build.
    StringHARDWAREThe name of the hardware (from the kernel command line or /proc).
    StringHOST?
    StringIDEither a changelist number, or a label like "M4-rc20".
    StringMANUFACTURERThe manufacturer of the product/hardware.
    StringMODELThe end-user-visible name for the end product.
    StringPRODUCTThe name of the overall product.
    StringRADIOThe radio firmware version number.
    StringSERIALA hardware serial number, if available.
    StringTAGSComma-separated tags describing the build, like "unsigned,debug".
    longTIME?
    StringTYPEThe type of build, like "user" or "eng".
    StringUNKNOWNValue used for when a build property is unknown.
    StringUSER

    ?

    ?

    ?

    明確幾個概念:

    ?

    SIM卡存儲的數據可分為四類:

    第一類是固定存放的數據。這類數據在移動電話機被出售之前由SIM卡中心寫入,包括國際移動用戶識別號(IMSI)、鑒權密鑰(KI)、鑒權和加密算法等等。

    第二類是暫時存放的有關網絡的數據。如位置區域識別碼(LAI)、移動用戶暫時識別碼(TMSI)、禁止接入的公共電話網代碼等。

    第三類是相關的業務代碼,如個人識別碼(PIN)、解鎖碼(PUK)、計費費率等。

    第四類是電話號碼簿,是手機用戶隨時輸入的電話號碼。用戶全部資料幾乎都存儲在SIM卡內,因此SIM卡又稱為用戶資料識別卡。

    ?

    IMSI是一個唯一的數字, 標識了GSM和UMTS?網絡里的唯一一個用戶.?它存儲 在手機的SIM卡里,它會通過手機發送到網絡上.?IMSI?與?SIM唯一對應

    IMEI也是一串唯一的數字, 標識了?GSM?和?UMTS網絡里的唯一一個手機.它通常被打印在手機里電池下面的那一面,撥?*#06#?也能看到它.?IMEI?與?設備唯一對應.

    1。IMEI不存在于SIM卡中,它是手機本身的串號。?
    2。通常我們所說的手機號也不存在于SIM卡中,雖然SIM卡中有一個專門存儲SIM卡本身號碼的地方,但是此號碼是通過手工設定的,而且是可以更改的。?SIM卡的識別通常使用IMSI號,這個對于SIM卡是唯一的。?
    3。使用SimGetRecordInfo之類的函數獲得SIM卡的IMSI號碼能否成功依賴于設備制造商是否實現了此函數,據我所知在DOPOD的機器上是可以獲得,但是在聯想的機器上卻不行,其他機器沒有。?
    4。獲得IMEI以及IMSI可以通過RIL或者TAPI中的LINE操作的函數獲得。

    ?

    ?

    記得添加權限:

    <uses-permission android:name="android.permission.READ_PHONE_STATE" />

    ?

    獲取手機屏幕高度:

  • private?void?getWeithAndHeight(){????
  • ????????????//這種方式在service中無法使用,????
  • ????????????DisplayMetrics?dm?=?new?DisplayMetrics();????
  • ????????????getWindowManager().getDefaultDisplay().getMetrics(dm);????
  • ????????????String?width?=?dm.widthPixels;??????????????//寬????
  • ????????????String?height?=?dm.heightPixels;???????????//高????
  • ?????????
  • ????????????//在service中也能得到高和寬????
  • ????????????WindowManager?mWindowManager?=?(WindowManager)?getSystemService(Context.WINDOW_SERVICE);????
  • ????????????width?=?mWindowManager.getDefaultDisplay().getWidth();????
  • ????????????height?=?mWindowManager.getDefaultDisplay().getHeight();????
  • ????????}??


  • 獲取手機MAC地址:

    ?

  • private?String?getMacAddress(){????
  • ?????????????String?result?=?"";????
  • ?????????????WifiManager?wifiManager?=?(WifiManager)?getSystemService(Context.WIFI_SERVICE);????
  • ?????????????WifiInfo?wifiInfo?=?wifiManager.getConnectionInfo();????
  • ?????????????result?=?wifiInfo.getMacAddress();????
  • ?????????????Log.i(TAG,?"macAdd:"?+?result);????
  • ?????????????return?result;????
  • ?????}??
  • ?

    ?

    手機CPU信息

    ?

    ?

  • private?String[]?getCpuInfo()?{????
  • ?????????????String?str1?=?"/proc/cpuinfo";????
  • ?????????????String?str2?=?"";????
  • ?????????????String[]?cpuInfo?=?{"",?""};??//1-cpu型號??//2-cpu頻率????
  • ?????????????String[]?arrayOfString;????
  • ?????????????try?{????
  • ?????????????????FileReader?fr?=?new?FileReader(str1);????
  • ?????????????????BufferedReader?localBufferedReader?=?new?BufferedReader(fr,?8192);????
  • ?????????????????str2?=?localBufferedReader.readLine();????
  • ?????????????????arrayOfString?=?str2.split("\\s+");????
  • ?????????????????for?(int?i?=?2;?i?<?arrayOfString.length;?i++)?{????
  • ?????????????????????cpuInfo[0]?=?cpuInfo[0]?+?arrayOfString[i]?+?"?";????
  • ?????????????????}????
  • ?????????????????str2?=?localBufferedReader.readLine();????
  • ?????????????????arrayOfString?=?str2.split("\\s+");????
  • ?????????????????cpuInfo[1]?+=?arrayOfString[2];????
  • ?????????????????localBufferedReader.close();????
  • ?????????????}?catch?(IOException?e)?{????
  • ?????????????}????
  • ?????????????Log.i(TAG,?"cpuinfo:"?+?cpuInfo[0]?+?"?"?+?cpuInfo[1]);????
  • ?????????????return?cpuInfo;????
  • ?????????}??
  • ?

    ?

    獲取手機可用內存和總內存:

  • private?String[]?getTotalMemory()?{????
  • ????????????String[]?result?=?{"",""};??//1-total?2-avail????
  • ????????????ActivityManager.MemoryInfo?mi?=?new?ActivityManager.MemoryInfo();??????
  • ????????????mActivityManager.getMemoryInfo(mi);??????
  • ????????????long?mTotalMem?=?0;????
  • ????????????long?mAvailMem?=?mi.availMem;????
  • ????????????String?str1?=?"/proc/meminfo";????
  • ????????????String?str2;????
  • ????????????String[]?arrayOfString;????
  • ????????????try?{????
  • ????????????????FileReader?localFileReader?=?new?FileReader(str1);????
  • ????????????????BufferedReader?localBufferedReader?=?new?BufferedReader(localFileReader,?8192);????
  • ????????????????str2?=?localBufferedReader.readLine();????
  • ????????????????arrayOfString?=?str2.split("\\s+");????
  • ????????????????mTotalMem?=?Integer.valueOf(arrayOfString[1]).intValue()?*?1024;????
  • ????????????????localBufferedReader.close();????
  • ????????????}?catch?(IOException?e)?{????
  • ????????????????e.printStackTrace();????
  • ????????????}????
  • ????????????result[0]?=?Formatter.formatFileSize(this,?mTotalMem);????
  • ????????????result[1]?=?Formatter.formatFileSize(this,?mAvailMem);????
  • ????????????Log.i(TAG,?"meminfo?total:"?+?result[0]?+?"?used:"?+?result[1]);????
  • ????????????return?result;????
  • ????????}??

  • 獲取手機安裝的應用信息(排除系統自帶):

  • private?String?getAllApp()?{????
  • ?????????????String?result?=?"";????
  • ?????????????List<PackageInfo>?packages?=?getPackageManager().getInstalledPackages(0);????
  • ?????????????for?(PackageInfo?i?:?packages)?{????
  • ?????????????????if?((i.applicationInfo.flags?&?ApplicationInfo.FLAG_SYSTEM)?==?0)?{????
  • ?????????????????????result?+=?i.applicationInfo.loadLabel(getPackageManager()).toString()?+?",";????
  • ?????????????????}????
  • ?????????????}????
  • ?????????????return?result.substring(0,?result.length()?-?1);????
  • ?????} ?
  • 轉載于:https://www.cnblogs.com/jiayaguang/p/4369155.html

    總結

    以上是生活随笔為你收集整理的[转] android获取手机信息大全的全部內容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。