How to get your application to tell the user that a new version is out on android markets?
<p>I would like to implement a check in my application to tell the user when I have distributed a new version out on android markets. Any ideas of an easy and good way to implement this check?</p>

<p><strong>Update</strong> This is how i resolved it:</p>

<pre><code>private static int getManifestVersionCode(Activity activity) {
    try {
        PackageInfo pinfo = activity.getPackageManager().getPackageInfo(activity.getPackageName(), 0);
        return pinfo.versionCode;
    } catch (NameNotFoundException e) {
    }
    return 0;
}

private static int getRemoteVersionCode() {
    BufferedReader reader = null;
    try {
        URL url = new URL("http://myserver.com/my_version_code.html");
        reader = new BufferedReader(new InputStreamReader(url.openStream(), "UTF-8"));
        String line = reader.readLine();
        return Integer.parseInt(line); 
    }catch (Exception e) {
    }finally {
        if (reader != null){ 
            try { 
                reader.close(); 
            } catch (IOException logOrIgnore) {
            }
        }
    }
    return 0;
}
</code></pre>
