android 获取系统硬件信息

一,首先设置权限访问:

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

二,逻辑代码获取系统硬件信息:

package com.wangfubin.getmyphoneinformation;

import org.w3c.dom.UserDataHandler;

import android.R.id;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import android.telephony.TelephonyManager;
import android.util.Log;
/**
 *
 * @ClassName: MainActivity
 * @Description: TODO(获取系统硬件信息)
 *
 * @Author: 西北野狼
 * @Date: 2013-10-26 下午10:35:08
 *
 * @Update by: 西北野狼
 * @Update time: 2013-10-26 下午10:35:08
 *
 * 备注信息:
 * Build.BOARD // 主板   
 * Build.BRAND // android系统定制商 
 * Build.CPU_ABI // cpu指令集
 * Build.DEVICE // 设备参数
 * Build.DISPLAY // 显示屏参数
 * Build.FINGERPRINT // 硬件名称
 * Build.HOST   
 * Build.ID // 修订版本列表   
 * Build.MANUFACTURER // 硬件制造商
 * Build.MODEL // 版本   
 * Build.PRODUCT // 手机制造商
 * Build.TAGS // 描述build的标签
 * Build.TIME   
 * Build.TYPE // builder类型
 * Build.USER
 */
public class MainActivity extends Activity {
    private String phoneNumber;
    private String phoneModel;
    private String SdkVersion;
    private String OsVersion;
    private String board;
    private String brand;
    private String cpu_abi;
    private String device;
    private String display;
    private String fingerprint;
    private String host;
    private String updateId;
    private String manufacturer;
    private String product;
    private String tags;
    private long time;
    private String type;
    private String user;


    private static final String TAG = "MainActivity";
    @SuppressLint("NewApi")
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        TelephonyManager phoneMgr=(TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);
        //经过测试,无法获取
        phoneNumber = phoneMgr.getLine1Number();
        Log.i(TAG, "电话号码:"+phoneNumber);

        phoneModel = Build.MODEL;
        Log.i(TAG, "手机型号:"+phoneModel);

        SdkVersion = Build.VERSION.SDK;
        Log.i(TAG, "SDK版本:"+SdkVersion);

        OsVersion = Build.VERSION.RELEASE;
        Log.i(TAG, "系统版本:"+OsVersion);

        board = Build.BOARD;
        Log.i(TAG, "主板:"+board);

        brand = Build.BRAND;
        Log.i(TAG, "android系统定制商:"+brand);

        cpu_abi = Build.CPU_ABI;
        Log.i(TAG, "cpu指令集:"+cpu_abi);

        device = Build.DEVICE;
        Log.i(TAG, "设备参数:"+device);

        display =Build.DISPLAY;
        Log.i(TAG, "显示屏参数:"+display);
        
        // 硬件名称
        fingerprint = Build.FINGERPRINT;
        Log.i(TAG, "硬件名称:"+fingerprint);
        
        host = Build.HOST;
        Log.i(TAG, "host:"+host);
        
        // 修订版本列表
        updateId = Build.ID;
        Log.i(TAG, "修订版本列表:"+updateId);
        
        // 硬件制造商
        manufacturer = Build.MANUFACTURER;
        Log.i(TAG, "硬件制造商:"+manufacturer);
        
        // 手机制造商
        product = Build.PRODUCT;
        Log.i(TAG, "手机制造商:"+product);
        
        // 描述build的标签
        tags = Build.TAGS;
        Log.i(TAG, "描述build的标签:"+tags);
        
        time = Build.TIME;
        Log.i(TAG, "time:"+time);
        
        // builder类型
        type = Build.TYPE;
        Log.i(TAG, "builder类型:"+type);
        
        user = Build.USER;
        Log.i(TAG, "user型:"+user);
    }
}

 



 

posted @ 2013-10-26 23:19  西北野狼  阅读(1207)  评论(0编辑  收藏  举报