哎 这个为什么总是报错呢 我已经想了好几天了
贴代码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)); }}
解决方案 »
- 求助,获取手机号
- 关于在service中实例化socket问题
- 请问各位 为何 做android 腾讯微博 和 新浪微博的自动登陆??
- android TCP协议实现,两只android手机通信不能正常通信
- android里头有没有类似iphone badge的属性
- 求助! android 基础教程 数独例子 出错
- 新人求教!!!如何获得发送邮件的android permission
- android自学已经差不多了,有什么项目可以推荐的吗
- 正则表达式用来查询哪一段中有abc并且有rt的方法是什么呢?
- 为什么在layout_gravity中center_horizontal不生效, 而center却可以?
- 请问这是什么文件?该怎么解析?是调用新浪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的日志贴出来