More robust way to get application icon on Android for notification #669
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Firstly, thank you so much for developing such a great library! I'm excited to say that I've been having good success getting it to work with Panda3D applications. There's one main obstacle that I can't overcome without changes to plyer, though.
Currently, the Notification implementation on Android makes the bold assumption that there is an R.class which has a field named "icon" that points to the icon resource of the application. This need not be the case; the icon may not be named "icon" precisely, or there may not even be an R.class at all, since this is not actually required by Android, and it would be very painful to try and get Panda3D's packaging tool to compile an R.class file specifically for the sake of getting plyer to work.
So, this PR instead changes the mechanism to use the PackageManager to determine the actual icon used by the application, regardless of its resource name. This should produce equivalent results without requiring an R.class or hardcoding the name of the icon resource.
This change has the additional benefit that it will prefer the icon of the Activity over that of the Application, if present, in cases where there are multiple activities in the same application (though I'm not married to this if this is considered undesirable). I believe p4a uses the same icon for both so it should not negatively affect p4a.
Likely also fixes #591 .
Thanks for your consideration!