b.i
b.i

Reputation: 1107

android: error parsing package

I am downloading an app in Android from a server and saving it to the internal memory:

URLConnection connection = url.openConnection();
connection.connect();
// download the file
InputStream input = new BufferedInputStream(url.openStream());
OutputStream output = new FileOutputStream(getFilesDir() + "/filename");
byte data[] = new byte[1024];
while ((count = input.read(data)) != -1) {
output.write(data, 0, count);
}
output.flush();
output.close();
input.close();

When the download is completed, a notification appears. When the notification is clicked, the app should be installed.

Intent i = new Intent(Intent.ACTION_VIEW);
i.setDataAndType(Uri.fromFile(new File(getFilesDir()+ "/filename")),"application/vnd.android.package-archive");
PendingIntent act = PendingIntent.getActivity(MainActivity._activity,0, i, 0);
notification.setLatestEventInfo("TEXT", "TEXT, act);

But when I click the notification, a dialog box saying: Error parsing package appears. Why?

Upvotes: 1

Views: 906

Answers (1)

Prem
Prem

Reputation: 4821

Another application with the same package name might be already installed in the device. So you are getting the error.

Upvotes: 1

Related Questions