1

Hi for college i try to write an android app with python and kivy. At the moment i run everything with testdata but i want to use real data if possible. So my question is: Is there a way to use the android api via python or kivy to get all installed apps on a android phone?

final Intent mainIntent = new Intent(Intent.ACTION_MAIN, null);
mainIntent.addCategory(Intent.CATEGORY_LAUNCHER);
final List pkgAppsList = context.getPackageManager().queryIntentActivities( mainIntent, 0); 

this is my code i used in my testapp on android/java.

best regards

4

1 回答 1

1

You can use pyjnius from within your kivy/non-kivy app. Here is a session using kivy-remote-shell for testing purposes.

>>> from jnius import autoclass, cast

>>> PythonActivity = autoclass('org.renpy.android.PythonActivity')
>>> Intent = autoclass('android.content.Intent') 
>>> context = cast('android.content.Context', PythonActivity.mActivity)
>>>
>>> intent = Intent() 
>>> intent.setAction(Intent.ACTION_MAIN)
>>> intent.addCategory(Intent.CATEGORY_LAUNCHER)
>>> lst = context.getPackageManager().queryIntentActivities(intent, 0).toArray()
>>> print lst

[<android.content.pm.ResolveInfo at 0x52454f60 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1da00696 at 0x4f75f7b0>>, <android.content.pm.ResolveInfo at 0x525542d0 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d800686 at 0x4f75f700>>, <android.content.pm.ResolveInfo at 0x525541e0 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d800682 at 0x4f75f720>>, <android.content.pm.ResolveInfo at 0x52554240 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d80067e at 0x4f75f730>>, <android.content.pm.ResolveInfo at 0x52554300 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d80067a at 0x4f75f740>>, <android.content.pm.ResolveInfo at 0x52554330 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d800676 at 0x4f75f750>>, <android.content.pm.ResolveInfo at 0x52554360 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x20400672 at 0x4f75f760>>, <android.content.pm.ResolveInfo at 0x52554390 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d70066e at 0x4f75f3f0>>, <android.content.pm.ResolveInfo at 0x525543c0 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d70066a at 0x4f75f780>>, <android.content.pm.ResolveInfo at 0x525543f0 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d700666 at 0x4f75f7a0>>, <android.content.pm.ResolveInfo at 0x52554420 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d700662 at 0x4f75f340>>, <android.content.pm.ResolveInfo at 0x52554450 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d70065e at 0x4f75f880>>, <android.content.pm.ResolveInfo at 0x52554480 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d70065a at 0x4f75f870>>, <android.content.pm.ResolveInfo at 0x525544b0 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d700656 at 0x4f75f890>>, <android.content.pm.ResolveInfo at 0x525544e0 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d700652 at 0x4f75f8a0>>, <android.content.pm.ResolveInfo at 0x52554510 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d70064e at 0x4f75f8b0>>, <android.content.pm.ResolveInfo at 0x52554540 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d70064a at 0x4f75f8c0>>, <android.content.pm.ResolveInfo at 0x52554570 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d700646 at 0x4f75f8d0>>, <android.content.pm.ResolveInfo at 0x525545a0 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d700642 at 0x4f75f8e0>>, <android.content.pm.ResolveInfo at 0x525545d0 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d70063e at 0x4f75f8f0>>, <android.content.pm.ResolveInfo at 0x52554600 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d70063a at 0x4f75f900>>, <android.content.pm.ResolveInfo at 0x52554630 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d700636 at 0x4f75f910>>, <android.content.pm.ResolveInfo at 0x52554660 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d700632 at 0x4f75f920>>, <android.content.pm.ResolveInfo at 0x52554690 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d70062e at 0x4f75f930>>, <android.content.pm.ResolveInfo at 0x525546c0 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d70062a at 0x4f75f940>>, <android.content.pm.ResolveInfo at 0x525546f0 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d700626 at 0x4f75f950>>, <android.content.pm.ResolveInfo at 0x52554720 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d700622 at 0x4f75f960>>, <android.content.pm.ResolveInfo at 0x52554750 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d70061e at 0x4f75f970>>, <android.content.pm.ResolveInfo at 0x52554780 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d70061a at 0x4f75f980>>, <android.content.pm.ResolveInfo at 0x525547b0 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d700616 at 0x4f75f990>>, <android.content.pm.ResolveInfo at 0x525547e0 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d700612 at 0x4f75f9a0>>, <android.content.pm.ResolveInfo at 0x52554810 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d70060e at 0x4f75f9b0>>, <android.content.pm.ResolveInfo at 0x52554840 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x2be0060a at 0x4f75f9c0>>, <android.content.pm.ResolveInfo at 0x52554870 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x22b00606 at 0x4f75f9d0>>, <android.content.pm.ResolveInfo at 0x525548a0 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1da00602 at 0x4f75f9e0>>, <android.content.pm.ResolveInfo at 0x525548d0 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d8005fe at 0x4f75f9f0>>, <android.content.pm.ResolveInfo at 0x52554900 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d8005fa at 0x4f75fa00>>, <android.content.pm.ResolveInfo at 0x52554930 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d7005f6 at 0x4f75fa10>>, <android.content.pm.ResolveInfo at 0x52554960 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d7005f2 at 0x4f75f5d0>>, <android.content.pm.ResolveInfo at 0x52554990 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d7005ee at 0x4f75fa40>>, <android.content.pm.ResolveInfo at 0x525549c0 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d7005ea at 0x4f75fa50>>, <android.content.pm.ResolveInfo at 0x525549f0 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d7005e6 at 0x4f75fa60>>, <android.content.pm.ResolveInfo at 0x52554a20 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d7005e2 at 0x4f75fa70>>, <android.content.pm.ResolveInfo at 0x52554a50 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1f8005de at 0x4f75fa80>>, <android.content.pm.ResolveInfo at 0x52554a80 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d6005da at 0x4f75fa90>>, <android.content.pm.ResolveInfo at 0x52554ab0 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d6005d6 at 0x4f75faa0>>, <android.content.pm.ResolveInfo at 0x52554ae0 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d6005d2 at 0x4f75fab0>>, <android.content.pm.ResolveInfo at 0x52554b10 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d6005ce at 0x4f75fac0>>, <android.content.pm.ResolveInfo at 0x52554b40 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d6005ca at 0x4f75fad0>>, <android.content.pm.ResolveInfo at 0x52554b70 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d6005c6 at 0x4f75fae0>>, <android.content.pm.ResolveInfo at 0x52554ba0 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d6005c2 at 0x4f75faf0>>, <android.content.pm.ResolveInfo at 0x52554bd0 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d6005be at 0x4f75fb00>>, <android.content.pm.ResolveInfo at 0x52554c00 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d6005ba at 0x4f75fb10>>, <android.content.pm.ResolveInfo at 0x52554c30 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d6005b6 at 0x4f75fb20>>, <android.content.pm.ResolveInfo at 0x52554c60 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d6005b2 at 0x4f75fb30>>, <android.content.pm.ResolveInfo at 0x52554c90 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d5005ae at 0x4f75fb40>>, <android.content.pm.ResolveInfo at 0x52554cc0 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d5005aa at 0x4f75fb50>>, <android.content.pm.ResolveInfo at 0x52554cf0 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d5005a6 at 0x4f75fb60>>, <android.content.pm.ResolveInfo at 0x52554d20 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d5005a2 at 0x4f75fb70>>, <android.content.pm.ResolveInfo at 0x52554d50 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d50059e at 0x4f75fb80>>, <android.content.pm.ResolveInfo at 0x52554d80 jclass=android/content/pm/ResolveInfo jself=<LocalRef obj=0x1d50059a at 0x4f75fb90>>]
于 2013-11-10T10:33:51.757 回答