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

Fix crash in Android Notification (SDK_INT >= 26) #543

Merged
merged 1 commit into from Mar 19, 2020
Merged

Fix crash in Android Notification (SDK_INT >= 26) #543

merged 1 commit into from Mar 19, 2020

Conversation

ghost
Copy link

@ghost ghost commented Mar 10, 2020

This pull request fixes the following error appearing in SDK_INT >= 26:

JNI DETECTED ERROR IN APPLICATION: bad arguments passed to
java.lang.Object android.app.Activity.getSystemService(java.lang.String)

It seems that the error is happening because there is a bug in pyjnius
where getSystemService(java.lang.Class) is not recognized. So, instead
of using getSystemService(manager), _get_notification_service is
used, which returns (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE).

Fixes #504, Fixes #533

This commit fixes the following error appearing in SDK_INT >= 26:

```
JNI DETECTED ERROR IN APPLICATION: bad arguments passed to
java.lang.Object android.app.Activity.getSystemService(java.lang.String)
```

It seems that the error is happening because there is a bug in pyjnius
where `getSystemService(java.lang.Class)` is not recognized. So, instead
of using `getSystemService(manager)`, `_get_notification_service` is
used, which returns `(NotificationManager)
getSystemService(Context.NOTIFICATION_SERVICE)`.
@MarkHession
Copy link

This fix worked for me! Had the bad arguments error and this fixed it.

@Robinosius
Copy link

Works for me as well on Android 10, thanks a lot!

@Zen-CODE Zen-CODE merged commit ead73cd into kivy:master Mar 19, 2020
@Zen-CODE
Copy link
Member

@franccisco Thanks :-)

@ghost ghost deleted the fix-android-notification branch March 21, 2020 20:02
AndreMiras pushed a commit to AndreMiras/plyer that referenced this pull request Apr 24, 2023
This commit fixes the following error appearing in SDK_INT >= 26:

```
JNI DETECTED ERROR IN APPLICATION: bad arguments passed to
java.lang.Object android.app.Activity.getSystemService(java.lang.String)
```

It seems that the error is happening because there is a bug in pyjnius
where `getSystemService(java.lang.Class)` is not recognized. So, instead
of using `getSystemService(manager)`, `_get_notification_service` is
used, which returns `(NotificationManager)
getSystemService(Context.NOTIFICATION_SERVICE)`.
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.

Notification not working on android
3 participants