AppListManager
📱 AppListManager (Android Library) makes managing application and activity lists easy.
Install / Use
/learn @LayoutXML/AppListManagerREADME
AppListManager (Android Library)

AppListManager is easy to use Android library, which minimizes developing time when working on application or activity lists. You no longer have to worry about asynchronous tasks, memory leaks and intent receivers. This library provides a simple way to receive application and activity lists as they change.
To receive application and activity lists using this library you must implement listeners and invoke methods. Additionally, to receive these lists automatically you must also register a receiver (in the manifest file and code). All listeners must be registered, and all unfinished tasks must be destroyed. Guide below explains exactly how to do all that. You can also inspect the included sample app that uses most of the features.
Download sample app from the Google Play store.
Step 1: Add the JitPack repository in your root build.gradle at the end of repositories:
allprojects {
repositories {
...
maven { url 'https://jitpack.io' }
}
}
Step 2. Add the dependency:
dependencies {
implementation 'com.github.LayoutXML:AppListManager:2.1.0'
}
Foreword
Project was started before learning any best practises or gaining experiance through work or studies and was intended to gain this experience. There are many things I would change and refactor if I were to start this project again. For now, it stays as a reminder of where it all started.
Table of Contents
- How to use - basic features
- How to use - advanced features
- More on each method and listener
- Other Information
- Changelog (external file)
How to use - basic features
Getting apps
-| Method | Listener --- | --- | --- Get all apps | AppList.getAllApps(...) | appListener(...) Get some apps (filtered list) | AppList.getSomeApps(...) | appListener(...) Get all new apps | AppList.getAllNewApps(...) | newAppListener(...) Get some new apps (filtered list) | AppList.getSomeNewApps(...) | newAppListener(...) Get all uninstalled apps | AppList.getAllUninstalledApps(...) | uninstalledAppListener(...) Get some uninstalled apps | AppList.getSomeUninstalledApps(...) | uninstalledAppListener(...)
newAppListener and uninstalledAppListener are also invoked automatically in the foreground (on all Android versions) and in the background (on Android versions 7.1.1 and lower).
Getting activities
-| Method | Listener --- | --- | --- Get all<sup>1</sup> activities | AppList.getAllActivities(...) | activityListener(...) Get some activities (filtered list) | AppList.getSomeActivities(...) | activityListener(...) Get all<sup>1</sup> new activities | AppList.getAllNewActivities(...) | newActivityListener(...) Get some new activities (filtered list) | AppList.getSomeNewActivities(...) | newActivityListener(...) Get all<sup>1</sup> uninstalled activities | AppList.getAllUninstalledActivities(...) | uninstalledActivityListener(...) Get some uninstalled activities | AppList.getSomeUninstalledActivities(...) | uninstalledActivityListener(...)
<sup>1</sup> - all activities with the intent.
newActivityListener and uninstalledActivityListener are also invoked automatically in the foreground (on all Android versions) and in the background (on Android versions 7.1.1 and lower).
Registering listeners
You must register all listeners that are implemented in your application by using AppList.registerListeners(...) and adding listeners names (or classes names if classes implement listeners) in this order:<br>appListener, activityListener, newAppListener, newActivityListener, uninstalledAppListener, uninstalledActivityListener, sortListener.
You can register listeners only once if listeners do not change but if you have multiple receivers across different classes feel free to re-register every time you want to change it.
Destroying unfinished tasks
You must destroy all unfinished tasks when the activity is being closed, changes or is restarted by using AppList.destroy() to not create memory leaks.
For example, you can destroy unfinished tasks in activity's onPause method.
Registering a receiver
If your application supports Android versions 7.1.1 or lower (not necessarily limited to these versions) and you want to receive application and activity lists automatically, you must add this to your AndroidManifest.xml file between application tags:
<receiver
android:name="com.layoutxml.applistmanagerlibrary.AppList"
android:enabled="true"
android:exported="true">
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_REMOVED" />
<data android:scheme="package" />
</intent-filter>
</receiver>
If your application supports Android versions 8.0 and higher (not necessarily limited to these versions) and you want to receive application and activity lists automatically, you must add this to your application, for example to onCreate method:
if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
registerReceiver(new AppList(),AppList.intentFilter);
Working with AppDatas
AppData object contains these properties of applications and activities:
- Name (String) - application or activity name you would want to display.
- Icon (Drawable) - application or activity icon you would want to display.
- Flags (Integer) - application flags. For activities it's still application flags.
- ActivityName (String) - activity name you would want to use for identifying or launching activities. For applications this variable is set to null.
- PackageName (String) - application package name. For activities it's still application package name.
- Permissions (String[]) - application permissions. For activities it's still application permissions.
- Object (Object (any object type)) - additional variable that you can use for your own needs. If you need multiple variables, create a new wrapper object (new type) to hold those variables.
All these variables have getters and setters that can be used with .set<Name> and .get<Name>. For example, package name can be accessed with .getPackageName() and .setPackageName(String).
All these variables except for PackageName can be null (for example received from broadcast receivers).
How to use - advanced features
Sorting
AppListManager library provides a method and a listener to sort your application and activity lists.
Method AppList.sort takes 4 arguments - app list (what to sort), two integer arguments that describe how to sort and a unique identifier:
- Second argument describes by what - it can be
AppList.BY_APPNAME,AppList.BY_APPNAME_IGNORE_CASEorAppList.BY_PACKAGENAME(BY_APPNAMEwould sort {ab,AA,BA} as {AA,BA,ab} andBY_APPNAME_IGNORE_CASEas {AA,ab,BA}). - Third argument describes in what order - it can be
AppList.IN_ASCENDINGorAppList.IN_DESCENDING.
Comparing
Because we can not get app names, icons and other data of already uninstalled apps, method .equals() is overridden to compare by pac
