Reputation: 1122
I have an Application which displays data sent from other applications. My Application can be launched from a Chooser (ShareSheet) if multiple Apps are installed on the phone that can view that file. Also, I need to get the source Application that is trying to open its file in my Application.
To achieve the above requirement, I have been using AccessibilityService
to fetch the last used app using accessibilityEvent.packagename
API (complete code below), and it worked fine till Android 13.
override fun onAccessibilityEvent(event: AccessibilityEvent?) {
if (event!!.packageName != "android" && event.packageName != null && shouldCaptureEvent(event)) {
Log.e(TAG, "Package name launched : " + event.packageName)
}
}
private fun shouldCaptureEvent(event: AccessibilityEvent?) : Boolean {
return event!!.eventType == AccessibilityEvent.TYPE_VIEW_CLICKED ||
event.eventType == AccessibilityEvent.TYPE_VIEW_FOCUSED ||
event.eventType == AccessibilityEvent.TYPE_VIEW_SELECTED
}
However above code is not working as expected in Android 14.
Reason:
event.packageName
is giving com.android.intentresolver
all the time my Application is opened from Chooser as there are below mentioned changes in Android 14.
As per docs,
The share sheet feature is no longer handled by the OS framework. Instead, it is handled by a system app called “IntentResolver”.
Because of which the last app is always com.android.intentresolver
. So, how can I get the source Application launching that ShareSheet?
I really appreciate any help you can provide.
UPDATE - This is only happening on Samsung device
Upvotes: 0
Views: 384