A Kotlin Android BroadcastReceiver implementation that facilitates log collection and sharing between Android applications and the Neat Log Aggregator service.
The NeatLogSampleBroadcastReceiver
enables applications to participate in centralized log collection by responding to broadcast intents from the Neat Log Aggregator service and sharing log files securely using Android's FileProvider API.
Add the following FileProvider configuration to your AndroidManifest.xml:
<provider
android:name=".NeatLogSampleFileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
<queries>
<package android:name="no.neat.logaggregator" />
</queries>
Create a file at res/xml/file_paths.xml
with the following content:
<paths>
<files-path name="neatlog" path="neatlog/" />
</paths>
Register the receiver in the manifest for the following actions:
no.neat.logaggregator.ACTION_LOG_COLLECTION_REGISTER
no.neat.logaggregator.ACTION_RECEIVE_LOGS
no.neat.logaggregator.ACTION_LOG_COLLECTION_COMPLETED
If you register via context then keep in mind that you will not receive any broadcast for these actions unless your apps process is running. (Even if your app is in the bg it will receive)
ACTION_LOG_COLLECTION_REGISTER
: Initiates registrationACTION_RECEIVE_LOGS
: Requests log filesACTION_LOG_COLLECTION_COMPLETED
: Signals completion
ACTION_RECEIVE_LOG_ACTION_REGISTER_REQUEST
: Registration requestACTION_SEND_LOGS
: Sends log file URIs
EXTRA_LOG_COLLECTION_PACKAGE_NAME
: Sender's package nameEXTRA_LOG_COLLECTION_IDEMPOTENCY_KEY
: Unique collection IDEXTRA_LOG_COLLECTION_FILE_URIS
: Array of file URIs
To test the log collection functionality:
- Install the sample app on a Neat device
- Trigger log collection using one of these methods:
- From Pulse:
- Navigate to the device page
- Click "Submit logs" button
- From Remote Access:
- Navigate to the device page
- Click "Generate logs" button
- From Pulse:
- The log collection process will start automatically and files will be shared with the Log Aggregator service