Android代码片段:设备信息
生活随笔
收集整理的這篇文章主要介紹了
Android代码片段:设备信息
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
設備ID
/*** Use for getting your device id if available.** @param context* @return your device id*/public static String getDeviceId(Context context) {TelephonyManager telephonyManager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);return telephonyManager.getDeviceId();}獲取APP圖標
/*** use for getting application Icon.** @param mContext* @return Icon as drawable from the application*/public static Drawable getAppIcon(Context mContext) {Drawable icon = null;final PackageManager pm = mContext.getPackageManager();String packageName = mContext.getPackageName();try {icon = pm.getApplicationIcon(packageName);return icon;} catch (NameNotFoundException e1) {e1.printStackTrace();}return null;}結束
總結
以上是生活随笔為你收集整理的Android代码片段:设备信息的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Android 使用SWIG生成Jni代
- 下一篇: Android代码片段:验证数据