python-for-android icon indicating copy to clipboard operation
python-for-android copied to clipboard

added support for include xml elements inside <manifest><application> AndroidManifest.xml

Open dvjdjvu opened this issue 3 years ago • 18 comments

My changes affect builddozer and python-for-kivy.

I added support for add rules for autostart. Now you can use section in buildozer.spec:

android.extra_manifest_application = %(source.dir)s/xml/receivers.xml

1 updated android.extra_manifest_application to android.extra_manifest_application_entry (see below) 2 updated android.extra_manifest_application_entry to android.extra_manifest_application_xml (see below)

for add rules in AndroidManifest.xml for autostart:

<receiver android:name=".MyBroadcastReceiver" android:enabled="true" android:exported="true">
    <intent-filter>
        <action android:name="android.intent.action.BOOT_COMPLETED" />
        <action android:name="android.intent.action.QUICKBOOT_POWERON" />
        <action android:name="com.htc.intent.action.QUICKBOOT_POWERON" />
    </intent-filter>
</receiver>

This is article doesn't work Starting Kivy App and Service on bootup on Android

dvjdjvu avatar Oct 21 '22 14:10 dvjdjvu

Went from a deeper test of these changes.

Related changes in buildozer work correctly. But in python-for-android (here) a problem exists with the name of the entry. It was surprising to see, that the new entry was accepted by p4a even before any adaptations have been done.

After application of the proposed changes to p4a nothing changed. The new entry was accepted, but ignored.

The problem seems to be the name. Because its a substring of another option. This might be a bug somwhere in p4a or maybe in the argument parsing library used.

After replaceing 'extra-manifest-application' to 'extra-manifest-application-entry' all over buildozer and p4a the change will work.

lufebe16 avatar Dec 13 '22 20:12 lufebe16

The problem seems to be the name. Because its a substring of another option. This might be a bug somwhere in p4a or maybe in the argument parsing library used.

Yes, when I did test project (article, git), I got this problem, but when I do this decide local, everything work.

After replaceing 'extra-manifest-application' to 'extra-manifest-application-entry' all over buildozer and p4a the change will work.

I think this way true. I will change code.

dvjdjvu avatar Dec 14 '22 12:12 dvjdjvu

I did it. Updated to "extra-manifest-application-entry".

dvjdjvu avatar Dec 14 '22 13:12 dvjdjvu

May I ask when these changes will be merged, I also encountered these problems. My project needs to reset the buildozer package every time, which makes it troublesome for me to modify its source code

Duke0425 avatar Jan 19 '23 06:01 Duke0425

image I don't know. Somebody who have accesses must approve merge pull request.

dvjdjvu avatar Jan 19 '23 10:01 dvjdjvu

image I don't know. Somebody who have accesses must approve merge pull request.

@tshirtman @matham If the modification is correct, can it be merged into? Please click approve, I am still modifying the library code during development, which makes me a headache

Duke0425 avatar Feb 02 '23 06:02 Duke0425

can we get an update on this please? these changes will allow for starting on boot and restarting when reinstalled etc. the java/android hooks are necessary. this will take kivy/python-for-android to the next level and allow python apps/services to better hook into android.

js-teevee avatar Feb 13 '23 17:02 js-teevee

Hi @misl6. I did the review.

dvjdjvu avatar Feb 16 '23 11:02 dvjdjvu

And I added choice type start service START_STICKY, START_NOT_STICKY and START_REDELIVER_INTENT. Default use now and before START_NOT_STICKY, but when you close app, service close too.

And I used this code for restart service.

PythonService = autoclass('org.kivy.android.PythonService')
PythonService.mService.setAutoRestartService(True)

Now you can use

PythonService.mService.setTypeStartSticky()
PythonService.mService.setTypeStartNotSticky()
PythonService.mService.setTypeStartRedeliverIntent()

With setTypeStartNotSticky, service doesnt close when app swipping or close.

dvjdjvu avatar Feb 16 '23 11:02 dvjdjvu

@dvjdjvu Can we keep the additions (START_STICKY/START_NOT_STICKY/START_REDELIVER_INTENT) into a different PR?

Feel free to ping me when you're ready with the review!

misl6 avatar Feb 16 '23 21:02 misl6

Ok @misl6. You can merge this pull request and close it. I won't do anything else here. I removed the changes START_STICKY from here. We need to close this section.

I will open new pull request for START_STICKY/START_NOT_STICKY/START_REDELIVER_INTENT.

dvjdjvu avatar Feb 17 '23 13:02 dvjdjvu

Hi @misl6, I did everythings. I hope.

dvjdjvu avatar Feb 20 '23 12:02 dvjdjvu

Hello @misl6, you did update? Please do it. (I updated my project, and all edits are gone :(( )

dvjdjvu avatar May 11 '23 15:05 dvjdjvu

any news? this is blocking

CristianPi avatar Jun 30 '23 22:06 CristianPi

@misl6 @lufebe16 @js-teevee, I updated the PR to the latest versions of the source code.

dvjdjvu avatar Sep 25 '23 15:09 dvjdjvu

@dvjdjvu I found your article today while learning Kivy and researching how to build a service that can keep running when the app closes or the phone is restarted. Thanks for the work you put out there!

I was able to build and deploy your code to my docker-android container and pushed my logic to a fork from kivy_service_test. Hopefully this can help people to use your logic untill they merge it.

If you want I can do a PR to your repo. Here is my fork that can help out by installing your python-for-android and buildozer fork via git with poetry:

kwuite avatar Oct 01 '23 22:10 kwuite

So is this completely dead? I just ran into the need to register a receiver in the manifest, and manually editing the template doesn't feel like a very robust or portable solution. Given the other facilities in buildozer to mutate the generated manifest, I'm surprised this functionality hasn't been merged yet/wasn't just included from the beginning.

colebrooks avatar Mar 26 '24 22:03 colebrooks