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

Broadcast parameter sent via not taking effect #3117

Open
tsiens opened this issue Mar 5, 2025 · 3 comments
Open

Broadcast parameter sent via not taking effect #3117

tsiens opened this issue Mar 5, 2025 · 3 comments
Labels
need-analysis need-discussion The issue or pull request needs a discussion to take a team decission

Comments

@tsiens
Copy link

tsiens commented Mar 5, 2025

Success in PC

adb shell am broadcast -a android.intent.action.shbl.shut_down --ei  time 6666

Faild in Phone

from jnius import autoclass

mActivity = autoclass('org.kivy.android.PythonActivity').mActivity
Intent = autoclass('android.content.Intent')
intent = Intent("android.intent.action.shbl.shut_down")
intent.putExtra("time", 6666)
mActivity.sendBroadcast(intent)

Can receive broadcast, but did not receive parameter “time“

@kuzeyron kuzeyron added need-analysis need-discussion The issue or pull request needs a discussion to take a team decission labels Mar 5, 2025
@RobertFlatt
Copy link
Contributor

I suspect this is about Android behavior rather than p4a or pyjnius behavior.

There are plenty of examples of putExtra using pyjnius. For example https://github.com/Android-for-Python/androidstorage4kivy/blob/main/src/androidstorage4kivy/chooser.py#L28. The functionality of the Java is transparent to pyjnius.

This might be a permissions issue, adb has root permission, the app has app permission.

This might be an api issue. I suggest you check the Android documentation for "android.intent.action.shbl.shut_down" (I can't find any!) for a documented "time" extra.
For example https://developer.android.com/reference/android/content/Intent#ACTION_SHUTDOWN does not have a "time" extra.

@tsiens
Copy link
Author

tsiens commented Mar 7, 2025

I suspect this is about Android behavior rather than p4a or pyjnius behavior.

There are plenty of examples of putExtra using pyjnius. For example https://github.com/Android-for-Python/androidstorage4kivy/blob/main/src/androidstorage4kivy/chooser.py#L28. The functionality of the Java is transparent to pyjnius.

This might be a permissions issue, adb has root permission, the app has app permission.

This might be an api issue. I suggest you check the Android documentation for "android.intent.action.shbl.shut_down" (I can't find any!) for a documented "time" extra. For example https://developer.android.com/reference/android/content/Intent#ACTION_SHUTDOWN does not have a "time" extra.

I tried to make the system print out the received broadcast, but found that putExtra can only emit a string equivalent to es, but the broadcast requires ei numbers, and all receivers cannot recognize the parameters

@RobertFlatt
Copy link
Contributor

I'm sorry I don't know what es and ei number are.

Its not clear to me that this is a p4a issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
need-analysis need-discussion The issue or pull request needs a discussion to take a team decission
Projects
None yet
Development

No branches or pull requests

3 participants