How can kivy app autostart on boot? (Android)

823 views
Skip to first unread message

John Xu

unread,
Apr 1, 2016, 10:55:07 PM4/1/16
to Kivy users support
I've searched for quite a while, but except following page, I can't get any info:

https://github.com/kivy/kivy/wiki/Starting-Kivy-service-on-bootup-%28Android%29

And I followed instructions/codes on above page, still can't get my app started on boot.
Android once told me "MyApp failed to start", but now, no messages at all.

Is there still no way to start python app directly?  But to have to use above wiki mentioned, a java class instead? Is above java class to start a python service, or a python activity?

ZenCODE

unread,
Apr 2, 2016, 9:40:17 AM4/2/16
to Kivy users support
Are you sure your services is not trying to create any GUI component or show a window? Services are not allowed to do this.. (as far as I know :-))
Message has been deleted

John Xu

unread,
Apr 2, 2016, 9:22:24 PM4/2/16
to Kivy users support
So kivy can't auto start PythonActivity (GUI) on boot, but only PythonService?

Maybe you can give me one more explanation. The above wiki code:

==========================================
package org.myproject.myapp;  
import android.content.BroadcastReceiver;  
import android.content.Intent;  
import android.content.Context;  
import org.renpy.android.PythonActivity;  
public class MyBroadcastReceiver extends BroadcastReceiver {   
   public void onReceive(Context context, Intent intent) {   
         Intent ix = new Intent(context,PythonActivity.class);   
         ix.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);    
         context.startActivity(ix);    
    }      
}  
===========================================

"where org.myproject.myapp is the package in question specified in your build parameters. "

My question is about the "package org.myproject.myapp;" -- My apk was also
packed as "org.myproject.myapp". And my Java friend told me, one java file
can only have one class, so 2 java files can't have exactly same
"package" name. Will they conflict each other?

ZenCODE

unread,
Apr 3, 2016, 12:55:40 AM4/3/16
to Kivy users support
Re: only a PythonService on boot, that's my guess. When building our service, it died immediately it tried to create a Window. You can text my theory by not doing anything in the startup code but log stuff. My bet is it should then work. Note that we've only build a normal service that is started by the app, not a startup service like yourself. But essentially, they should be exactly the same thing.

Re: package name. Not sure. But you're not creating a java files. Your package name looks fine , so I doubt this is an issue...

John Xu

unread,
Apr 3, 2016, 1:30:12 AM4/3/16
to Kivy users support
Thanks for answer.

Again, for above wiki code,
 
> context.startActivity(ix);

My question is, are we only able to have one service in one
kivy app? (Service file named: service/main.py)

And how can I tell above "startActivity(ix)" is not starting
the PythonAcitivty (GUI) thread, but service/main.py the
PythonService thread?

ZenCODE

unread,
Apr 3, 2016, 2:46:05 AM4/3/16
to Kivy users support

My question is, are we only able to have one service in one
kivy app? (Service file named: service/main.py)

As far as I can tell. Never tried to make 2, but it's not obvious how one would make another as the naming is implicit. But you can pass parameters to it. So perhaps you could make do with one service and pass it parameters if you want it to do different things?
 

And how can I tell above "startActivity(ix)" is not starting
the PythonAcitivty (GUI) thread, but service/main.py the
PythonService thread?

Log it and see. Just make sure your logging starts from other things are imported i.e. right at the top of your main.py.

 

Alexander Taylor

unread,
Apr 3, 2016, 7:22:38 AM4/3/16
to Kivy users support
The new python-for-android toolchain, with the new SDL2 bootstrap, supports multiple services and a wider range of service configurations.

John Xu

unread,
Apr 4, 2016, 9:21:49 AM4/4/16
to Kivy users support
I followed instructions on above kivy wiki,
but I got following error report on boot up "adb logcat". What have I done wrong? I did put the MyAutostartReceiver.java in:

.buildozer/android/platform/python-for-android/dist/default/src/MyAutostartReceiver.java

and did register the receiver in

.buildozer/android/platform/python-for-android/dist/myapp/templates/AndroidManifest.tmpl.xml

====================================================
java.lang.ClassNotFoundException: Didn't find class "org.test.myapp.MyAutostartReceiver" on path: DexPathList[[zip file "/data/app/org.test.myapp-2.apk"],nativeLibraryDirectories=[/data/app-lib/org.test.myapp-2, /vendor/lib, /system/lib, /data/datalib]],at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56),at java.lang.ClassLoader.loadClass(ClassLoader.java:497),at java.lang.ClassLoader.loadClass(ClassLoader.java:457),at android.app.ActivityThread.handleReceiver(ActivityThread.java:2475) }
====================================================

saband

unread,
Oct 22, 2017, 9:17:38 PM10/22/17
to Kivy users support
Have you solved this problem? Because I have almost the same: https://groups.google.com/forum/#!topic/kivy-users/aE0KNiruhpc

понедельник, 4 апреля 2016 г., 9:21:49 UTC-4 пользователь John Xu написал:
Reply all
Reply to author
Forward
0 new messages