If I'm using an accessibility service to get the activity that user currently has opened anywhere on their device, is event.getClassName()
enough to distinguish this activity from any other activity on the device?
@Override
public void onAccessibilityEvent(AccessibilityEvent event) {
if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
Log.i(TAG, event.getClassName());
}
}
So is it enough or is it possible that getClassName()
might be the same for another activity? Meaning do I have to include event.getPackageName()
as well to ensure the activity name is unique?
CodePudding user response:
is it possible that getClassName() might be the same for another activity?
Yes. This is especially true for apps that use third-party libraries that supply activities.
do I have to include event.getPackageName() as well to ensure the activity name is unique?
Yes. This is why ComponentName
needs both the application ID and the class name.