📱 AppListManager (Android Library) makes managing application and activity lists easy.

Overview

AppListManager (Android Library)

Android Arsenal Build Status GitHub Version API Donate

Logo

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

  1. How to use - basic features
    1. Getting apps
    2. Getting activities
    3. Registering listeners
    4. Destroying unfinished tasks
    5. Registering a receiver
    6. Working with AppDatas
  2. How to use - advanced features
    1. Sorting
    2. Comparing
    3. Checking and filtering applications by their flags
    4. Checking and filtering applications by their permissions
    5. More on flags
  3. More on each method and listener
    1. Methods
    2. Listeners
  4. Other Information
    1. Sample app
    2. Versioning
    3. Author
    4. License
  5. 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 all1 activities AppList.getAllActivities(...) activityListener(...)
Get some activities (filtered list) AppList.getSomeActivities(...) activityListener(...)
Get all1 new activities AppList.getAllNewActivities(...) newActivityListener(...)
Get some new activities (filtered list) AppList.getSomeNewActivities(...) newActivityListener(...)
Get all1 uninstalled activities AppList.getAllUninstalledActivities(...) uninstalledActivityListener(...)
Get some uninstalled activities AppList.getSomeUninstalledActivities(...) uninstalledActivityListener(...)

1 - 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:
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:

  1. Name (String) - application or activity name you would want to display.
  2. Icon (Drawable) - application or activity icon you would want to display.
  3. Flags (Integer) - application flags. For activities it's still application flags.
  4. ActivityName (String) - activity name you would want to use for identifying or launching activities. For applications this variable is set to null.
  5. PackageName (String) - application package name. For activities it's still application package name.
  6. Permissions (String[]) - application permissions. For activities it's still application permissions.
  7. 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:

  1. Second argument describes by what - it can be AppList.BY_APPNAME, AppList.BY_APPNAME_IGNORE_CASE or AppList.BY_PACKAGENAME (BY_APPNAME would sort {ab,AA,BA} as {AA,BA,ab} and BY_APPNAME_IGNORE_CASE as {AA,ab,BA}).
  2. Third argument describes in what order - it can be AppList.IN_ASCENDING or AppList.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 package names. This includes .contains(), .remove(), .removeAll() and others.

Checking and filtering applications by their permissions

It is possible to filter application lists received by appListener, newAppListener, activityListener, newActivityListener by permissions lists. If application contains at least one given permission, it is returned to these listeners. You can also access individual application's permissions list using getPermissions method.

Additionally, you can check whether an individual application uses (i.e. has it in its manifest file) at least one of the given permissions by using AppList.checkApplicationPermissions(...) with 2 arguments - application (or activity) and permissions. When checking an activity, method checks its application permissions.

Checking and filtering applications by their flags

  • Application flags:
    It is possible to filter application lists received by appListener, newAppListener, activityListener, newActivityListener by any combination of these flags and their opposites (if FLAG_SYSTEM filter returns a list of not updated systems apps, the opposite would be all user apps and updated system apps).
    Additionally, you can check whether an individual application contains any combination of flags by using AppList.checkFlags(...) with 3 arguments - application (or activity), flags (these) and whether to match them or not. When checking an activity, method checks its application flags and not activity flags.

  • Activity flags:
    You can also access individual application's flags using .getFlags method. It is also possible to filter activity lists received by activityListener, newActivityListener with any combination of these flags.

More on flags

To set multiple application flags you can use any combination of these operators:

  • & - AND operator. Adds apps that have all filters.
  • | - OR operator. Adds apps that have any of the given filters.
  • ^ - XOR (exclusive or) operator. Adds apps that have one but not the other filter.

More on each method and listener

Methods

Methods for applications:

  1. getAllApps.

    Takes 2 arguments: Context and Integer (unique identifier for your personal use).

    Used to receive all installed application list (unfiltered and unsorted).
  2. getSomeApps.

    Takes 6 arguments: Context, Integer (application flags), Boolean (whether to find applications that match the flags or not), String[] (permissions), Boolean (whether to find applications that contain at least one of the permissions or not) and Integer (unique identifier).

    Used to receive filtered installed application list (unsorted). For non applicable parameters use null or false (for booleans).
  3. getAllNewApps.

    Takes 3 arguments: Context, List (current application list), and Integer (unique identifier).

    Used to receive all application list that are not in the given list (unfiltered and unsorted).
  4. getSomeNewApps.

    Takes 7 arguments: Context, List (current application list), Integer (application flags), Boolean (whether to find applications that match the flags or not), String[] (permissions), Boolean (whether to find applications that contain at least one of the permissions or not) and Integer (unique identifier).

    Used to receive filtered application list that are not in the given list (unsorted). Does not remove applications that do not have given flags from the given list. For non applicable parameters use null or false (for booleans).
  5. getAllUninstalledApps.

    Takes 3 arguments: Context, List (current application list), and Integer (unique identifier).

    Used to receive all application list that are no longer installed (unfiltered and unsorted).
  6. getSomeUninstalledApps.

    Takes 7 arguments: Context, List (current application list), Integer (application flags), Boolean (whether to find applications that match the flags or not), String[] (permissions), Boolean (whether to find applications that contain at least one of the permissions or not) and Integer (unique identifier).

    Used to receive a list of applications that are not in the filtered currently installed application list. For non applicable parameters use null or false (for booleans).

Methods for activities:

  1. getAllActivities.

    Takes 3 arguments: Context, Intent, and Integer (unique identifier).

    Used to receive all activity list with the intent (unfiltered and unsorted).
  2. getSomeActivities.

    Takes 8 arguments: Context, Intent, Integer (activity flags), Integer (application flags), Boolean (whether to find applications that match the flags or not), String[] (permissions), Boolean (whether to find applications that contain at least one of the permissions or not) and Integer (unique identifier).

    Used to receive filtered activity list (unsorted). If "activity flags" not applicable - write 0, for other non applicable parameters use null or false (for booleans).
  3. getAllNewActivities.

    Takes 4 arguments: Context, List (current activity list), Intent, and Integer (unique identifier).

    Used to receive all activity lists that are not in the given list with the intent (unfiltered and unsorted).
  4. getSomeNewActivities.

    Takes 9 arguments: Context, List (current activity list), Intent, Integer (activity flags), Integer (application flags), Boolean (whether to find applications that match the flags or not), String[] (permissions), Boolean (whether to find applications that contain at least one of the permissions or not) and Integer (unique identifier).

    Used to receive filtered activity list that are not in the given list (unsorted). Does not remove activities that do not have given flags from the given list. If "activity flags" not applicable - write 0, for other non applicable parameters use null or false (for booleans).
  5. getAllUninstalledActivities.

    Takes 4 arguments: Context, List (current application list), Intent, and Integer (unique identifier).

    Used to receive all activity list that are no longer installed (unfiltered and unsorted).
  6. getSomeUninstalledActivities.

    Takes 9 arguments: Context, List (current application list), Intent, Integer (activity flags), Integer (application flags), Boolean (whether to find applications that match the flags or not), String[] (permissions), Boolean (whether to find applications that contain at least one of the permissions or not) and Integer (unique identifier).

    Used to receive a list of activities that are not in the filtered currently installed activity list . If "activity flags" not applicable - write 0, for other non applicable parameters use null or false (for booleans).

Other methods:

  1. registerListeners.

    Takes 7 arguments: AppListener, ActivityListener, NewAppListener, NewActivityListener, UninstalledAppListener, UninstalledActivityListener, SortListener. Must be listener names or classes names that implement these listeners. If listener is not used then write null.

    Explained in more detail in "Registering listeners" section here.
  2. checkApplicationPermissions.

    Takes 3 arguments: AppData (single application or activity), String[] (application permissions) and Boolean (whether the application must contain at least one of the permissions or not).

    Explained in more detail in "Checking and filtering applications by their permissions" section here.
  3. checkApplicationFlags.

    Takes 3 arguments: AppData (single application or activity), Integer (application flags), and Boolean (whether the application must match the flags or not).

    Explained in more detail in "Checking and filtering applications by their flags" section here.
  4. sort.

    Takes 4 arguments: List (application or activity lists that you want to be sorted), Integer (explains how to sort), Integer (explains how to sort), and Integer (unique identifier).

    Explained in more detail in "Sorting" section here.

Note: New application/activity list methods could be used to get application/activity list with different filters - method compares given (filtered) list with currently installed application/activity list and returns applications/activities that are in a currently installed application/activity list but not in the given (filtered) list.

Note: Uninstalled application/activity list methods could be used to get application/activity list with different filters - method compares given list with currently installed (filtered) application/activity list and returns applications/activities that are in the given list but not in the currently installed (filtered) application/activity list.

Listeners

Listeners for applications:

  1. appListener.
    Receives 6 arguments: List (your application list), Integer (application flags; if getAllApps was called, then it's null), Boolean (whether flags match applications; if getAllApps was called then it's false), String[] (permissions), Boolean (whether applications contain at least one of the given permissions or not) and Integer (unique identifier).
  2. newAppListener.
    Receives 7 arguments: List (your new application list), Integer (application flags; if getAllNewApps was called or from a broadcast receiver, then it's null), Boolean (whether flags match applications; if getAllNewApps was called or from a broadcast receiver, then it's false), Boolean (true when from broadcast receiver, otherwise false), String[] (permissions), Boolean (whether applications contain at least one of the given permissions or not) and Integer (unique identifier);
  3. uninstalledAppListener.
    Receives 7 arguments: List (your uninstalled application lists), Boolean (true when from broadcast receiver, otherwise false), Integer (application flags; if getAllUninstalledApps was called or from a broadcast receiver, then it's null), Boolean (whether flags match applications; if getAllUninstalledApps was called or from a broadcast receiver, then it's false), String[] (permissions), Boolean (whether applications contain at least one of the given permissions or not) and Integer (unique identifier; if from broadcast receiver, it's -1); If received from broadcast receiver, only package name is set to the AppData but applications can still be removed with .removeAll(...).

Listeners for activities:

  1. activityListener.
    Receives 8 arguments: List (your activity list), Intent, Integer (activity flags), Integer (application flags), Boolean (whether applications match the flags or not), String[] (permissions), Boolean (whether applications contain at least one of the given permissions or not) and Integer (unique identifier).
  2. newActivityListener.
    Receives 9 arguments: List (your new activity list), Intent, Integer (activity flags; if getAllNewActivities was called or from a broadcast receiver, then it's 0), Integer (application flags; if getAllNewActivities was called or from a broadcast receiver, then it's null), Boolean (whether flags match applications; if getAllNewActivities was called or from broadcast receiver, then it's false), Boolean (true when from broadcast receiver, otherwise false), String[] (permissions), Boolean (whether applications contain at least one of the given permissions or not) and Integer (unique identifier).
  3. uninstalledActivityListener.
    Receives 9 arguments: List (your uninstalled activity list), Intent, Integer (activity flags; if getAllUninstalledActivities was called or from a broadcast receiver, then it's 0), Integer (application flags; if getAllUninstalledActivities was called or from a broadcast receiver, then it's null), Boolean (whether flags match applications; if getAllUninstalledActivities was called or from broadcast receiver, then it's false), Boolean (true when from broadcast receiver, otherwise false), String[] (permissions), Boolean (whether applications contain at least one of the given permissions or not) and Integer (unique identifier; if from broadcast receiver, it's -1). If received from broadcast receiver, received list contains only 1 activity for every uninstalled application (with only package name set) but if the application has 2 activities that are in the list, they can still be removed with .removeAll(...).

Other listeners:

  1. sortListener.
    Receives 4 arguments: List (your sorted activities list), Integer (explains how to sort), Integer (explains how to sort), Integer (unique identifier). Explained in more detail in "Sorting" section here.

Other Information

Sample app

Sample app that showcases most of the features can be found in "app" folder in this repository. You can download pre-compiled version from the Google Play store here. Application contains two independent (for the most part) activities:

  1. MainActivity, which demonstrates these features:
    1. Receiving all applications (getAllApps).
    2. Receiving new applications (getAllNewApps and broadcast receiver).
    3. Receiving uninstalled applications (getAllUninstalledApps and broadcast receiver).
    4. Receiving some (system) applications (getSomeApps) with flags.
    5. Receiving all activities (with launcher intent) (getAllActivities).
    6. Receiving new activities (with launcher intent) (getAllNewActivities and broadcast receiver).
    7. Receiving uninstalled activities (with launcher intent) (getAllUninstalledActivities and broadcast receiver).
    8. Sorting (sort).
  2. ListActivity, which demonstrates these features:
    1. Showing spinning progress bar (loading) when waiting for application/activity list.
    2. Receiving all applications (getAllApps).
    3. Receiving all activities (with launcher intent) (getAllActivities).
    4. Showing application/activity list on screen.
    5. Receiving new applications (getAllNewApps and broadcast receiver).
    6. Receiving new activities (with launcher intent) (getAllNewActivities and broadcast receiver).
    7. Updating the list on screen with new applications/activities.
    8. Receiving uninstalled applications (getAllUninstalledApps and broadcast receiver).
    9. Receiving uninstalled activities (with launcher intent) (getAllUninstalledActivities and broadcast receiver).
    10. Updating the list on screen without uninstalled applications/activities.
    11. Sorting (sort).
    12. Launching applications and activities.

Logo by @mansya

Versioning

AppListManager library uses Semantic Versioning 2.0.0. Sample application version name matches library version used and version code matches number of commits at the moment of release.

Author

More information about me and my projects: https://rokasjankunas.com

License

AppListManager and a sample app are licensed under "MIT" license. Copyright laws apply.

Copyright © 2018 Rokas Jankūnas (LayoutXML)

You might also like...
Android 12 beta bug activity doesnt pause
Android 12 beta bug activity doesnt pause

android-12-beta-bug-activity-doesnt-pause Tracker link: https://issuetracker.google.com/u/1/issues/202616720 The issue: clicking the "Recent" button o

Quiz-Application - A quiz application which uses opentdb api to get quiz of different levels like Easy Hard and Medium
Quiz-Application - A quiz application which uses opentdb api to get quiz of different levels like Easy Hard and Medium

Quiz-Application A quiz application which uses opentdb api to get quiz of differ

A simple and easy to use stopwatch and timer library for android

TimeIt Now with Timer support! A simple and easy to use stopwatch and timer library for android Introduction A stopwatch can be a very important widge

A general purpose kotlin library that use kotlin coroutines, flows and channels to provide timer features with the most easy and efficient way

Timer Timer is a general purpose kotlin library that use kotlin coroutines, flows and channels to provide timer features with the most easy and effici

Abysl Asset Manager is an easy to use library management tool to index and search game assets
Abysl Asset Manager is an easy to use library management tool to index and search game assets

Abysl Asset Manager is an easy to use library management tool to index and search game assets. Features Itch.IO Library Import Hum

Android-easy-permissions-kt - EasyPermissionsKt - A lightweight Android library that abstracts all runtime permission boilerplate code to simplify the system permissions managemen 📱 Android Library to implement Rich, Beautiful, Stylish 😍 Material Navigation View for your project with Material Design Guidelines. Easy to use.
📱 Android Library to implement Rich, Beautiful, Stylish 😍 Material Navigation View for your project with Material Design Guidelines. Easy to use.

Material NavigationView for Android 📱 📱 Android Library to implement Rich, Beautiful Material Navigation View for your project with Material Design

An easy to use android library to let devs know how much internet-data their app is consuming
An easy to use android library to let devs know how much internet-data their app is consuming

EasyAnalytics! an easy to use android library to let developers know how much internet-data their app is consuming. We can identify this as we want ba

A powerful library for easy implementation of HMS Location Kit.

AdvancedLocation A powerful library for easy implementation of HMS Location Kit. 💙 Request location with couple lines of code (no more boilerplate) C

Comments
  • New logo/icon proposal

    New logo/icon proposal

    Good day sir. I am a graphic designer and i am interested in designing a logo for your good project. I will be doing it as a gift for free. I just need your permission first before I begin my design. Hoping for your positive feedback. Thanks

    enhancement 
    opened by mansya 7
  • No Apps displayed

    No Apps displayed

    I made a project. MainActivity with Fragment. I try to apply your methods inside the fragment with all the listeners but I cant get it to work. Though if I revert back to my implementation, my apps do get displayed.

    Inside onCreateView: AppList.registerListeners( this , null , null,null,null,null,this); apps = true; AppList.getAllApps( getActivity() , 0); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { getActivity().registerReceiver( new AppList() , AppList.intentFilter); }

    More tutorials are needed. Any guide here?

    opened by Allosh87 1
Releases(2.1.0)
  • 2.1.0(Nov 9, 2018)

    • Added a new generic type object to AppData (variable called object). It is an 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. Can be used with getObject() and setObject(Object), where Object is any type.
    Source code(tar.gz)
    Source code(zip)
  • 2.0.0(Oct 20, 2018)

    NOTE: This version introduces backwards incompatible changes. Follow the steps below on how to solve issues.

    • Added ability to filter by application permissions:
      • All getSome... methods now require two additional parameters - String[] (which contains permissions), and Boolean (which tells whether to look for applications that contain at least one of the given permissions or not).
      • All listeners (except for sortListener) - activityListener, appListener, newActivityListener, newAppListener, uninstalledActivityListener, uninstalledAppListener - now receive two additional parameters (look the point above). If not applicable, then they are null and false.
      • AppData object now holds application permissions (if you are working with activity lists, this field still contains application permissions) that can be accessed with getPermissions() and setPermissions(...).
      • checkApplicationPermissions method which allows checking whether a single AppData object contains (or does not contain) at least one of the given permissions.

    For more information read README.md.

    Source code(tar.gz)
    Source code(zip)
  • 1.1.0(Oct 4, 2018)

Owner
Rokas Jankunas
🇬🇧 🇱🇹 Mid-level Full Stack Software Developer. Featured on Gizmodo, Lifehacker, Android Authority, XDA-Developers
Rokas Jankunas
This library makes it easy for you to develop an simple drawing app in android

DrawingCanvas Library for drawing app canvas Features Size , transperancy and color manupulation of brush -- Using setSizeForBrush(), setBrushAlpha()

Mihir Shah 24 Nov 27, 2022
Project BlueWeather is an android app that lists the closest locations to you and shows the 7-day weather forecast for the location you select.

Project BLUEWEATHER Description Project BlueWeather is a weather forecast application for android. It lists the locations closest to you. It then prov

Burak Unutmaz 4 May 12, 2021
An android app that lists all planets in our solar system and brings some information about them.

SolarSystem This application was developed in Android Studio and uses Kotlin as programming language. In short, it is an app that lists all the planet

Dayon Oliveira 0 Nov 3, 2021
A console-based productivity app involving both To-Do Lists and Goal tracking

This is a console-based productivity app involving both To-Do Lists and Goal tracking. It allows users to create To-Dos, check them off, and filter the display between complete/incomplete items

Joel Jossie 3 Dec 25, 2022
Synapse Moderation Bot - A bot for managing and moderating our community Discord server

Synapse Moderation Bot A bot for managing and moderating our community Discord server. Note This bot is not public. While you can host it on your own,

Synapse Technologies, LLC 1 Jul 16, 2022
Alkatraz is an app that helps you to Reach your goals by managing your Habits .

Alkatraz - Build healthy habits for healthy life Alkatraz is an app that helps you to Reach your goals by managing your Habits . It's makes your life

Nishant Kumar 11 Nov 28, 2022
Gradlee plugin for managing jekyll workflows

JEKYLL GRADLE PLUGIN Gradle plugin providing easy configuration and tasks for managing your jekyll projects via gradle. Supports running via native je

Martynas Petuška 2 Apr 23, 2022
RoboDemo is a ShowCase library for Android to demonstrate to users how a given Activity works.

RoboDemo RoboDemo is a ShowCase library for Android to demonstrate to users how a given Activity works. A sample is available in the download area of

Stéphane Nicolas 220 Nov 25, 2022
Easy-Note - Easy Note Application will help user to add and update their important notes

Easy-Note ??️ Easy Note App helps you to create your notes. You can ?? edit and

Ade Amit 0 Jan 30, 2022
DessertPusher - A dessert app displaying the functionalities of activity lifecycle and fragments

Activity Lifecycle - DessertPusher This is the toy app for lesson 4 of the Andro

Brian Kubai 0 Jan 18, 2022