tags:

views:

94

answers:

2

Hi, Iam planning to create an app, and not to publish it at the google market. i want the users to update thire app once in a while when an updates will be rlsd via server(let's not get into the idea how i gonna do this)... so for this i need to give to each app some ID, so i know that that user gotta update his app, and not new installation (i wanna avoid the case the user will have two versions of the app).. and ofcourse install the app to new users. how could i sign those apps with version when i rls an update manually? mybe some other idea?

thanks, ray.

A: 

I wouldn't worry about signing them per say, why not just have a value in the strings.xml file that has the version number? A simply check against the value on the server could determine whether an update is necessary.

Chris Thompson
thanks, ill also try this solution
rayman
+3  A: 

You can use the android:versionCode and android:versionName attributes in the AndroidManifest.xml. That way, as long as the package name is the same it won't overlap and you can get that info like this to see if there is a newer version available:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="org.moo.android.myApp"
  android:versionCode="12"
  android:versionName="1.2.37">

Then you can read these values and compare with values on your server, like this:

try
{
    PackageManager manager = context.getPackageManager();
    PackageInfo info = manager.getPackageInfo("org.moo.android.myApp", 0);
    int code = info.versionCode;
    String name = info.versionName;

    // Compare with values on the server to see if there is a new version
}
catch(NameNotFoundException nnf)
{
    nnf.printStackTrace();
}
CaseyB
ill try that one, thanks!
rayman
+1 This is probably the "cleaner" version of what I suggested. (and frankly the way you're probably supposed to do it ;-) )
Chris Thompson