Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More robust way to get application icon on Android for notification #669

Merged
merged 1 commit into from
May 4, 2022
Merged

More robust way to get application icon on Android for notification #669

merged 1 commit into from
May 4, 2022

Conversation

rdb
Copy link
Contributor

@rdb rdb commented Mar 12, 2022

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!

rdb added a commit to panda3d/pyjnius that referenced this pull request Mar 12, 2022
It's convenient to put this Panda3D-specific hack in this repo for now, since we need to build custom Android wheels for pyjnius anyway
@Zen-CODE Zen-CODE merged commit 8a6ae05 into kivy:master May 4, 2022
@rdb rdb deleted the robust-app-icon branch May 5, 2022 07:31
rdb added a commit to panda3d/pyjnius that referenced this pull request Sep 6, 2022
It's convenient to put this Panda3D-specific hack in this repo for now, since we need to build custom Android wheels for pyjnius anyway
rdb added a commit to panda3d/pyjnius that referenced this pull request Oct 16, 2022
It's convenient to put this Panda3D-specific hack in this repo for now, since we need to build custom Android wheels for pyjnius anyway
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.

Plyer notification not working on android
2 participants