Open a file with Kivy app

625 views
Skip to first unread message

Degenerate Tech

unread,
Nov 3, 2020, 4:59:35 PM11/3/20
to Kivy users support
When we click on .html file in our computer it will open web browser..and then it will show information..

I want to make a image viewer Kivy app which will open The app when I will click on image from file manager ..it is possible ?

ElliotG

unread,
Nov 3, 2020, 5:06:41 PM11/3/20
to Kivy users support
Search:  How to associate a file with a program in Windows 

Degenerate Tech

unread,
Nov 3, 2020, 5:08:28 PM11/3/20
to Kivy users support
I want to do in android ..os 

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/kivy-users/f0599c15-dbeb-4745-a7fc-5aa095a60b9dn%40googlegroups.com.

Robert Flatt

unread,
Nov 3, 2020, 7:47:59 PM11/3/20
to Kivy users support
Same thing on Android (google is your friend)


On Tuesday, November 3, 2020 at 12:08:28 PM UTC-10, Degenerate Tech wrote:
I want to do in android ..os 

On Wed 4 Nov, 2020, 3:36 AM ElliotG, <elli...@cox.net> wrote:
Search:  How to associate a file with a program in Windows 


On Tuesday, November 3, 2020 at 2:59:35 PM UTC-7 sksah...@gmail.com wrote:
When we click on .html file in our computer it will open web browser..and then it will show information..

I want to make a image viewer Kivy app which will open The app when I will click on image from file manager ..it is possible ?

--
You received this message because you are subscribed to the Google Groups "Kivy users support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kivy-...@googlegroups.com.

Degenerate Tech

unread,
Nov 9, 2020, 5:35:11 AM11/9/20
to Kivy users support

Robert Flatt

unread,
Nov 9, 2020, 12:33:00 PM11/9/20
to Kivy users support
i want to do this ..
I get that you know what you are asking, but we don't.

Are you saying you want to write a Python app that:
1) receives messages from the Android system file picker?
or
2) opens the system file picker?
or
3) something else ?

Degenerate Tech

unread,
Nov 9, 2020, 1:16:28 PM11/9/20
to Kivy users support
I have three video player..in android os ..when I do click on video file through Android file manager a popup tell me choose video player ..by which I want to play that video...in general Kivy video player are not showing in that pop-up ...I want to play that video by Kivy video player through Android file manager ..by clicking on video file

Robert Flatt

unread,
Nov 9, 2020, 3:27:56 PM11/9/20
to Kivy users support
As I understand it you want an app that receives messages from the Android system file picker.

To my knowledge there is no Python example of this.

Since there is no free lunch, this requires reading a lot of Android documentation, reading some Java, using pyjnius, and possibly some new features in p4a.
The link you referenced contains a link for a place to start https://developer.android.com/training/sharing/receive

The Android documentation is great, but you have to read a lot of it to understand what they are thinking.
The documentation on the Python side (pyjnius, p4a) is very poor.
I find that tasks like this involve a lot of trial and error; sometimes too much.

If you want teach yourself how to use Android and pyjnius I suggest starting with a simpler task.

Degenerate Tech

unread,
Nov 9, 2020, 4:16:23 PM11/9/20
to Kivy users support
I don't know basics of Java Android ...
if .. please tell me how do I start ..

Robert Flatt

unread,
Nov 9, 2020, 4:39:02 PM11/9/20
to Kivy users support
Find an online tutorial you like.

Robert Flatt

unread,
Nov 10, 2020, 1:05:14 AM11/10/20
to Kivy users support
Here is a simple example to get you started. It displays text strings shared by some other app.

You would have to extend this to sharing videos, not difficult but you will have to read the the referenced Android documentation and perhaps more. No whining about you don't know Android, time to start teaching it to yourself.

Read the comments.

When you are done, please consider sharing the enhanced app with the Group.

main.py
from kivy.app import App
from kivy.uix.label import Label
from android import mActivity,autoclass

'''
buildozer.spec:
android.manifest.intent_filters = intent_filter.xml

Requires:
./intent_filter.xml
See:
https://developer.android.com/training/sharing/receive#handling-content
'''


Intent = autoclass('android.content.Intent')

class MyApp(App):
   
def handle_message(self):
       
# This must happen during build()
        intent
= mActivity.getIntent()
       
if Intent.ACTION_SEND == intent.getAction():
           
if "text/plain" == intent.getType():
                text
= intent.getStringExtra(Intent.EXTRA_TEXT)
               
if text:
                   
self.text = text
       
   
def build(self):
       
self.text ='No message'
       
self.handle_message()
       
return Label(text=self.text)

   
def on_pause(self):
       
# This is a hack so that the app will respond
       
# to a message after the app is paused.
       
# Obviously in a real app this would have side effects
       
#
       
# TODO Figure out how Android thinks this case should be handled.
       
return False

MyApp().run()


intent_filter.xml
   <intent-filter>
       
<action android:name="android.intent.action.SEND" />
       
<category android:name="android.intent.category.DEFAULT" />
       
<data android:mimeType="text/plain" />
   
</intent-filter>



Degenerate Tech

unread,
Nov 10, 2020, 1:48:43 AM11/10/20
to Kivy users support
what is XML file where I have to put this .?

Degenerate Tech

unread,
Nov 10, 2020, 1:52:04 AM11/10/20
to Kivy users support
I don't know intent mActivity ..what they do..

Robert Flatt

unread,
Nov 10, 2020, 11:41:32 AM11/10/20
to Kivy users support
Read the comments

Robert Flatt

unread,
Nov 10, 2020, 11:55:15 AM11/10/20
to Kivy users support

Degenerate Tech

unread,
Nov 10, 2020, 12:52:48 PM11/10/20
to Kivy users support
yes ..I have to read many things...then ..if I read java android ..so there no need of python Kivy .I can develop app using java android ..

Robert Flatt

unread,
Nov 10, 2020, 2:56:50 PM11/10/20
to Kivy users support
This addresses the paused app case, replace the MyApp class with:

class MyApp(App):  
   
def new_intent_handler(self,intent):

       
if Intent.ACTION_SEND == intent.getAction():
           
if "text/plain" == intent.getType():
                text
= intent.getStringExtra(Intent.EXTRA_TEXT)
               
if text:

                   
self.label.text = text

   
def build(self):
       
self.label = Label(text='No message')
       
self.new_intent_handler(mActivity.getIntent())
        activity
.bind(on_new_intent=self.new_intent_handler)
       
return self.label


Do whatever makes you happy.
Reply all
Reply to author
Forward
0 new messages