tags:

views:

62

answers:

1

Hi,

Here's the problem I'm facing: trying to do my own application update I download the update apk from a web server on the sd card and then I launch the Package Installer with the downloading path (while the old application is running). So far after the package installer starts and the user agrees to install the application I get the following message "MyApp Could not be installed on this phone" and in the logcat then following message is printed: "No package identifier when getting value for resource number 0x00000000". I could not find a reason for this behaviour, so please if there is something that I'm missing do point it to me!

try
 {
   BufferedInputStream getit = new BufferedInputStream(new URL("http://mywebserver:8080/myapk.apk").openStream());
   FileOutputStream saveit = new FileOutputStream(path);
   BufferedOutputStream bout = new BufferedOutputStream(saveit,1024);
   byte data[] = new byte[1024];
   int readed = getit.read(data,0,1024);
   while(readed != -1)
    {
        bout.write(data,0,readed);
        readed = getit.read(data,0,1024);
    }
    bout.close();
    getit.close();
    saveit.close();
}
catch(Exception e)
{
   e.printStackTrace
}
A: 

Try to use the following sample intead of the "package installer" version. The sample will not explain how to download the file from the server. It will assume it's already in a byte array.

byte[] data = dataReadFromServer;

FileOutputStream outStream = openFileOutput("somename.apk", Context.MODE_WORLD_READABLE);
outStream.write(data);
Intent intent = new Intent();
String absolutePath = "file://" + getFilesDir().getAbsolutePath() + "/" +
"somename.apk"; 
intent.setAction(android.content.Intent.ACTION_VIEW); 
intent.setDataAndType(Uri.parse(absolutePath), "application/vnd.android.package-archive"); 
startActivity(intent);
Flaviu Negrean
Actually that's how my code pretty much looks like, I have the downloaded apk in a file and then send an intent to start the Package Installer. If I put another application's apk, I can install it, but I cannot do that if the apk I try to install is an updated version of the current application (I increment the versionCode tag in the AndroidManifest.xml)
rantravee
PS I edited my post to display the server download
rantravee
Are you using this exact action: android.content.Intent.ACTION_VIEW?
Flaviu Negrean
Yes I am , but that's not the issue .As I discovered I was trying to update an aplication with debugable=true set, while the update apk was signed !
rantravee