android_launchable_apps 0.1.0 copy "android_launchable_apps: ^0.1.0" to clipboard
android_launchable_apps: ^0.1.0 copied to clipboard

PlatformAndroid

Flutter plugin that allows you to gather information for user launchable android apps.

android_launchable_apps #

Flutter plugin that allows you to gather information for user launchable android apps. Apps found are ones that declare a MAIN intent and LAUNCHER category.

    <queries>
        ...
        <intent>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent>
    </queries>

Getting Started #

For getting user launchable applications, simply call #

await AndroidLaunchableApps.getLaunchableApplications();

For getting usage stats for user launchable applications: #

Edit your AndroidManifest.xml to add

<!-- needed to be able to pull launchable apps -->
<queries>
    <intent>
        <action android:name="android.intent.action.MAIN"/>
        <category android:name="android.intent.category.LAUNCHER"/>
    </intent>
</queries>

Then add

<!-- needed for requesting permissions to query launchable app usage stats  -->
<uses-permission
    android:name="android.permission.PACKAGE_USAGE_STATS"
    tools:ignore="ProtectedPermissions" />

Since the above permissions uses "tools" you will need to edit your manifest tag to have that namespace

<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools">

In your code, you can check and request for the permission to query usage stats with

bool hasPermission = await AndroidLaunchableApps.isUsagePermissionGranted();
await AndroidLaunchableApps.requestUsagePermission();

Requesting this special permission will take the user to a special screen in the OS. They may be requested by the system to go somewhere else to further allow access to even permit the permission request. Therefore, it is highly recommended to develop your flow with this in mind.

To finally request the stats, simply call

final usages = await AndroidLaunchableApps.queryEvents(startDate, endDate);
1
likes
160
points
20
downloads

Publisher

verified publisherverseai.com

Weekly Downloads

Flutter plugin that allows you to gather information for user launchable android apps.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on android_launchable_apps

Packages that implement android_launchable_apps