//按下取得手機資訊
        button1.setOnClickListener(new Button.OnClickListener(){

            @Override
            public void onClick(View v) {
                phoneInfo="";
                phoneInfo += "DeviceId(IMEI) = " + tel.getDeviceId() + "\n";
                phoneInfo += "DeviceSoftwareVersion = " + tel.getDeviceSoftwareVersion()+ "\n";
                phoneInfo += "Line1Number = " + tel.getLine1Number() + "\n";
                phoneInfo += "NetworkCountryIso = " + tel.getNetworkCountryIso() + "\n";
                phoneInfo += "NetworkOperator = " + tel.getNetworkOperator() + "\n";
                phoneInfo += "NetworkOperatorName = " + tel.getNetworkOperatorName() + "\n";
                phoneInfo += "NetworkType = " + tel.getNetworkType() + "\n";
                phoneInfo += "honeType = " + tel.getPhoneType() + "\n";
                phoneInfo += "SimCountryIso = " + tel.getSimCountryIso() + "\n";
                phoneInfo += "SimOperator = " + tel.getSimOperator() + "\n";
                phoneInfo += "SimOperatorName = " + tel.getSimOperatorName() + "\n";
                phoneInfo += "SimSerialNumber = " + tel.getSimSerialNumber() + "\n";
                phoneInfo += "SimState = " + tel.getSimState() + "\n";
                phoneInfo += "SubscriberId(IMSI) = " + tel.getSubscriberId() + "\n";
                phoneInfo += "VoiceMailNumber = " + tel.getVoiceMailNumber() + "\n";
                
                
                new AlertDialog.Builder(mainActivity.this)
                .setTitle("手機資訊")
                .setMessage(phoneInfo).show();
            }
        });

AndroidManifest.xml 要加入權限
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>

,
創作者介紹

Mazs's Notes

cookiesp 發表在 痞客邦 PIXNET 留言(0) 人氣()