Regarding apk installation programatically & getting callback for successful installation.

868 views
Skip to first unread message

ashiq sayyad

unread,
Mar 1, 2012, 10:08:58 AM3/1/12
to Android Developers, android-...@googlegroups.com
Hi,

Hope all doing well.

I am trying to install app using following intent..

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(apkUri, "application/vnd.android.package-
archive");
startActivity(intent);

This will launch package installer screen with ok & cancel commands
(depends on device) for user approval.

If the user press Ok ,app will install & if user press
cancel,installation will decline..

Can I get these callbacks to my programme depending on user selection
means whether installation is successful or declined...

Do I need to specify some key in the intent to acieve this????

Thanks & Regards,
Ashiq sayyad

Josh Brown

unread,
Mar 2, 2012, 8:24:33 PM3/2/12
to android-...@googlegroups.com, Android Developers
There's the ACTION_PACKAGE_ADDED broadcast you could use to see when it's installed.  I don't think there's one for if it was declined, but you could use some trickery in your onResume().  The only problem is if they hit the home button when the installer is showing and then somehow navigate back to your app in such a way that they can still get back to the installer.

Chris Stratton

unread,
Mar 2, 2012, 8:43:34 PM3/2/12
to android-...@googlegroups.com, Android Developers
On Friday, March 2, 2012 8:24:33 PM UTC-5, Josh Brown wrote:
There's the ACTION_PACKAGE_ADDED broadcast you could use to see when it's installed.  I don't think there's one for if it was declined, but you could use some trickery in your onResume().  The only problem is if they hit the home button when the installer is showing and then somehow navigate back to your app in such a way that they can still get back to the installer.

Can't you just ask the package manager if it's (already) installed ?  If not you fire off another view intent to begin a new installation attempt.  You can't force the user to agree, but then your app doesn't have to go beyond that point if they don't.

Reply all
Reply to author
Forward
0 new messages