Skip to content

Fix: resolve mainTargetClassName correctly to handle activity aliases#7

Open
bunnyjaura wants to merge 1 commit intorafaelsetragni:mainfrom
bunnyjaura:fix/launcher-alias-resolution
Open

Fix: resolve mainTargetClassName correctly to handle activity aliases#7
bunnyjaura wants to merge 1 commit intorafaelsetragni:mainfrom
bunnyjaura:fix/launcher-alias-resolution

Conversation

@bunnyjaura
Copy link
Copy Markdown

Problem

When creating notifications in apps that use , the NotificationBuilder
was setting mainTargetClassName using only activityInfo.name. This caused a crash:

Attempt to invoke virtual method 'java.lang.String java.lang.Class.getName()'
on a null object reference

because the launcher alias did not have a direct activity class associated with it.

Solution

Updated updateMainTargetClassName() to:

  1. Check activityInfo.targetActivity first.
  2. Fall back to activityInfo.name if targetActivity is null.

This ensures that mainTargetClassName always points to a valid activity class,
even when the launcher entry is an alias.

Testing

  • Verified with normal launcher activity (no alias).
  • Verified with launcher alias.
  • Notifications now open the correct main activity in all cases without crashing.

Updated updateMainTargetClassName() to check activityInfo.targetActivity
before falling back to activityInfo.name. This ensures the correct main
activity is used when a launcher alias is defined.
@bunnyjaura
Copy link
Copy Markdown
Author

@rafaelsetragni

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant