android 检查当前版本信息,Android如何检查版本

做这样的事情

private int GetVersion()

{

int version = 0;

IPackageManager pm = ActivityThread.getPackageManager();

try

{

//returns a ref to my application according to its application name

ApplicationInfo applicationInfo = pm.getApplicationInfo("com.android.phonetests", 0);

if (applicationInfo != null)

{

version = applicationInfo.targetSdkVersion;

//2 is 5

//2.01 6 (Donut - 2.01)

//2.2 7 (Eclair - 2.2) currently it is Eclair_MR1 (Major Release)

switch (version)

{

case Build.VERSION_CODES.ECLAIR_MR1:

Log.i(LOG_TAG,"[DBG] version: ECLAIR");//2.2 7 (Eclair - 2.2) currently it is Eclair_MR1 (Major Release)

break;

case Build.VERSION_CODES.DONUT:

Log.i(LOG_TAG,"[DBG] version: DONUT");//2.01 6 (Donut - 2.01)

break;

}

}

}

catch (android.os.RemoteException e){}

return version;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值