哎 这个为什么总是报错呢 我已经想了好几天了
贴代码package jp.alldin.sdk.common;import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.NetworkInfo.State;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.widget.TextView;public class GetDeviceInfo{
TextView tv;
public Context AndroidContentContext; public GetDeviceInfo(Context paramContext) {
this.AndroidContentContext = paramContext.getApplicationContext();
} public String getDeviceBaicInfo() {
TelephonyManager tm = (TelephonyManager) ((GetDeviceInfo) this).AndroidContentContext.getSystemService("phone");
String str = "";
str += "DeviceId(IMEI) = " + tm.getDeviceId() + "\n";
str += "DeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion()+ "\n";
str += "Line1Number = " + tm.getLine1Number() + "\n";
str += "NetworkCountryIso = " + tm.getNetworkCountryIso() + "\n";
str += "NetworkOperator = " + tm.getNetworkOperator() + "\n";
str += "NetworkOperatorName = " + tm.getNetworkOperatorName() + "\n";
str += "NetworkType = " + tm.getNetworkType() + "\n";
str += "honeType = " + tm.getPhoneType() + "\n";
str += "SimCountryIso = " + tm.getSimCountryIso() + "\n";
str += "SimOperator = " + tm.getSimOperator() + "\n";
str += "SimOperatorName = " + tm.getSimOperatorName() + "\n";
str += "SimSerialNumber = " + tm.getSimSerialNumber() + "\n";
str += "SimState = " + tm.getSimState() + "\n";
str += "SubscriberId(IMSI) = " + tm.getSubscriberId() + "\n";
str += "VoiceMailNumber = " + tm.getVoiceMailNumber() + "\n";
return str; } public void getDeviceNwStatus() {
ConnectivityManager connManager = (ConnectivityManager)this.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connManager.getActiveNetworkInfo();
boolean available = networkInfo.isAvailable();
if(available)
{
Log.i("a", "a");
}
else
{
Log.i("b", "b");
}
android.net.NetworkInfo.State state = connManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState();
if(State.CONNECTED==state)
{
Log.i("c", "WIFI");
}
android.net.NetworkInfo.State state1 = connManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState();
if(State.CONNECTED==state)
{
Log.i("c", "GPRS");
}
startActivity(new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS));
startActivity(new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS)); }}
贴代码package jp.alldin.sdk.common;import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.NetworkInfo.State;
import android.telephony.TelephonyManager;
import android.util.Log;
import android.widget.TextView;public class GetDeviceInfo{
TextView tv;
public Context AndroidContentContext; public GetDeviceInfo(Context paramContext) {
this.AndroidContentContext = paramContext.getApplicationContext();
} public String getDeviceBaicInfo() {
TelephonyManager tm = (TelephonyManager) ((GetDeviceInfo) this).AndroidContentContext.getSystemService("phone");
String str = "";
str += "DeviceId(IMEI) = " + tm.getDeviceId() + "\n";
str += "DeviceSoftwareVersion = " + tm.getDeviceSoftwareVersion()+ "\n";
str += "Line1Number = " + tm.getLine1Number() + "\n";
str += "NetworkCountryIso = " + tm.getNetworkCountryIso() + "\n";
str += "NetworkOperator = " + tm.getNetworkOperator() + "\n";
str += "NetworkOperatorName = " + tm.getNetworkOperatorName() + "\n";
str += "NetworkType = " + tm.getNetworkType() + "\n";
str += "honeType = " + tm.getPhoneType() + "\n";
str += "SimCountryIso = " + tm.getSimCountryIso() + "\n";
str += "SimOperator = " + tm.getSimOperator() + "\n";
str += "SimOperatorName = " + tm.getSimOperatorName() + "\n";
str += "SimSerialNumber = " + tm.getSimSerialNumber() + "\n";
str += "SimState = " + tm.getSimState() + "\n";
str += "SubscriberId(IMSI) = " + tm.getSubscriberId() + "\n";
str += "VoiceMailNumber = " + tm.getVoiceMailNumber() + "\n";
return str; } public void getDeviceNwStatus() {
ConnectivityManager connManager = (ConnectivityManager)this.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connManager.getActiveNetworkInfo();
boolean available = networkInfo.isAvailable();
if(available)
{
Log.i("a", "a");
}
else
{
Log.i("b", "b");
}
android.net.NetworkInfo.State state = connManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState();
if(State.CONNECTED==state)
{
Log.i("c", "WIFI");
}
android.net.NetworkInfo.State state1 = connManager.getNetworkInfo(ConnectivityManager.TYPE_MOBILE).getState();
if(State.CONNECTED==state)
{
Log.i("c", "GPRS");
}
startActivity(new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS));
startActivity(new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS)); }}
解决方案 »
- @android:id/list 和@+id/android:list的区别。
- 有关expandablelistview添加按钮
- listview里,setselection(row)里如何置顶和不置顶?
- 怎么用程序去判断图片资源名为pic3 我就调用R.drawable.pic3
- android动态显示问题
- findPreference("individual_name").setEnabled(!findPreference("individual_name").
- android是否支持定时启动一个进程?
- Android中使用POI写入word,表格为什么不能超过六列?
- 如何加速二维码扫描
- sipdroid真的能视频通话么
- 请问这是什么文件?该怎么解析?是调用新浪API返回来的数据
- 请问一个apk调用多个apk以及自动卸载apk的问题。。。
ConnectivityManager connManager = (ConnectivityManager)this.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo networkInfo = connManager.getActiveNetworkInfo();
startActivity(new Intent(android.provider.Settings.ACTION_WIRELESS_SETTINGS));
startActivity(new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS));
把tag是AndroidRuntime的日志贴出来