I am trying to implement AUTOUPDATE functionality in my android app, as it is a custom app not published via android market. So far I have everything working, however android tries to install the App and says “APPLICATION NOT INSTALLED”. I don’t know if it is important, but the App is already on the device, so it is an update.
The app downloads the APK file from the internet and stores it on the SDcard. Than I do this:
Uri packageURI = Uri.parse("package:my_package");
Intent intent = new Intent(Intent.ACTION_VIEW, packageURI);
intent.setDataAndType(Uri.fromFile(new File(Environment.getExternalStorageDirectory() + "/download/" + ApkName)),
"application/vnd.android.package-archive");
startActivity(intent);
Here is a snippet I use, it looks basically the same as yours the only difference I can see is the use of packageURI. I don’t know if using the packageURI would cause it not to work, but if I were you I’d try without.
However generally when you see the “Application Not Installed” message while attempting to install it means that the signature used to sign the 2 apk’s was different i.e. one is release key signed, one is debug key signed. Or perhaps if the 2 apks were compiled on different computers you’ve got them signed with 2 different debug keys.
Note that even though you are not distributing via the market you still need to generate and sign your application. Debug key’s expire after 1 year which your app will stop working once the key has expired.