简体   繁体   中英

Install intent for local .apk file on gingerbread

When I installed new APK from another App on Android 2.1, I just used:

Intent intent2 = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new File(Environment.getExternalStorageDirectory()+"/Download/" + "app.apk")), "application/vnd.android.package-archive");
startActivity(intent2);

It opened new install dialog and i could use it.

Now, I try the same code on Gingerbread 2.3.3, and when I start this install intent, it shows me a selection "select action using application". With the following choices: Google talk, video, videotalk, DRM, Market.

What happened? Did the install intents changed in Gingerbread? How to make new install intent at Android Gingerbread? Thanks

The API reference says that there weren't any changes applied in startActivity(Intent) method. ACTION_VIEW launches the default activity to handle a piece of data or asks to choose one to make default (as I see). If you are getting the list of apps to launch then you don't have default action for this type of data. Also, check if non-market apps are enabled to be installed on your device.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM