Notes on "Upgrade all" apps implementation
Current "Upgrade app" progress
AppDetails decides if an app can be installed newly or upgraded.
* If the user clicks Install / Update, it will then create a new ApkDownloader. * When the ApkDownloader receives the download complete event, it asks android to install the file. * This is done by sending an Intent to the Android system, asking it to open the .apk file (then Android takes over and shows the install dialog).
Suggested "Upgrade app" progress
FDroid app has an "Update all" menu option.
When the user touches this button, it will query the AppProvider for all apps which can be upgraded, then iterate over these and:
* Start a new ApkDownloader for the first one * Listen for download complete event * Start a new Intent to ask Android to install it
(This is the same as what happens in the AppDetails class now).
If the apk is not installed (e.g. user clicks cancel), then don't bother continuing with other apps.
Finding apps which can be updated
First you need a reference to Context (these are everywhere in Android, and a lot of things either extend Context, or expose it via getContext().
Uri uri = AppProvider.getCanUpdateUri() Cursor result = context.getContentResolver.query( uri, AppProvider.DataColumns.ALL, ... ) List<App> appsToUpdate = AppProvider.Helper.cursorToList( result )