I did my application in 2.2 environment, when i install my apk in older version i am getting parser error. is there anything possibility to display our own message instead parser error message. As per my opinion it is not.
Asked
Active
Viewed 3,291 times
2 Answers
1
Do something like this
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;
}

Mark Mooibroek
- 7,636
- 3
- 32
- 53
-
-
Thanks for immediate replies. I have a doubt, can you explain about what you written in switch case. what Log should do,is that displaying error message or something other than this..?? – RAAAAM May 07 '11 at 05:23
0
As I understand it you build for version 2.2 and then you deploy it on an earlier version. Why don't you build it for that earlier version?
I don't think you can get another error than that parse error.

thoredge
- 12,237
- 1
- 40
- 55
-
Your idea is good, but what i am asking is in case if i install my apk in older version instead of 2.2, before installing the file i want to display the message like "sorry you need 2.2". is this possible to do in application perspective..?? – RAAAAM May 07 '11 at 07:50