I am trying to launch package installer to install an APK file that I have
already installed:
private void installApk(String file) {
Uri pkgUri = Uri.parse("file://" + file);
Intent intent = new Intent();
intent.setData(pkgUri);
intent.setClassName("com.android.packageinstaller",
"com.android.packageinstaller.PackageInstallerActivity");
startActivity(intent);
}
Now, this is all fishy, I know, depending on undocumented (?) behavior of
PackageInstallerActivity. My problem is I need to give a file that
PackageInstallerActivity can read.
I tried many things:
(1)
FileOutputStream fout = Context.openFileOutput("xxx.apk",
Context.MODE_WORLD_READABLE);
But this file is created in a directory /data/data/<app>/files, which is
mode drwx------, so other processes cannot read it.
(2)
File dir = Context.getDir("downloader", Context.MODE_WORLD_READABLE);
But there's no way for me to create a File inside the <dir> with world
readable permission
(3) this one works, but is extremely convulsing:
SharedPreferences pref =
mReader.getSharedPreferences("nubi.apk",
Context.MODE_WORLD_READABLE);
SharedPreferences.Editor editor = pref.edit();
editor.putInt("text_size", 0);
editor.commit();
file = mReader.getFilesDir().getParent() +
"/shared_prefs/xxx.apk.xml";
I tried this, and I was actually able to invoke the PackageInstallerActivity
to install my APK file. I tested on cupcake and 1.0 emulator.
On well....
I looked at the Browser, and it uses a permission
android.permission.ACCESS_DOWNLOAD_MANAGER
But this doesn't seem to be documented either. (See
http://groups.google.com/group/android-developers/browse_thread/thread/98f63d8bea48a34f
)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---