kivy + android intent filters











up vote
1
down vote

favorite












Im very new to kivy and python so I may have thrown myself in at the deep end here but i'm trying to figure out how to get an android intent and use it within a simple kivy app?



So im currently trying to figure out the basic design elements and just how to get stuff working. I want to be able to click on a link (for example) and launch my app and then do stuff, nothing too complicated, it just needs to be able to get the link which is passed to it from android.



I figured out this was to do with android intent filters and added the appropriate "intent_filters.xml" file to make this work.
So clicking on the link will launch my app, which is good.



However I cant figure out then how to parse the information passed to the app in android. So below is a very simple app with a button and I just want to update the button to see if my intent is being picked up or not.



Currently clicking the button causes the app to close. When i test this in the Kivy VM I am using to compile the apk it will close with a message that "platform" is not defined (which makes sense as its not in android) but it doesnt much help with testing or tracking down how to make it work.



I've read some stuff which seems to suggest that this might not be possible with kivy?
Can anyone confirm if this is possible in kivy and if so, how?
(i've tried variations on activity.getIntent(), intent.getData(), Intent.getIntent().getStringExtra(Intent.EXTRA_TEXT), Intent().getData().getPath() all to no avail)



from kivy.app import App

from kivy.uix.button import Button
from kivy.uix.boxlayout import BoxLayout


class TutorialApp(App):

def build(self):
self.gen_btn = Button(text='Initial',
size_hint=(.90, .10),
pos=(5, 5),
font_size=50)
self.gen_btn.bind(on_press=self.update_tutorialapp)
l = BoxLayout()
l.add_widget(self.gen_btn)
return l

def update_tutorialapp(self, *args):
st = update_button()
st.update_Message(self)

class update_button():

def update_Message(self, source):
source.gen_btn.text = "the event was called"
if platform=="android":
from jnius import cast
from jnius import autoclass
import android
import android.activity

# test for an intent passed to us
PythonActivity = autoclass('org.renpy.android.PythonActivity')
activity = PythonActivity.mActivity
intent = activity.getIntent()
intent_data = intent.getData()

source.gen_btn.text = PythonActivity.getIntent().getStringExtra(Intent.EXTRA_TEXT)

if __name__ == "__main__":
TutorialApp().run()









share|improve this question






















  • Hi, if your app crash, then please report the log associated to the crash. What does it tells you?
    – tito
    Nov 12 at 12:40










  • Well the only way I have to run it on Android currently is to copy it to my phone so I don't really get any messages when it crashes. If I enable logging/debugging when I create the APK would I be able to retrieve any useful information from a non rooted android phone (ie from the apps install directory within android)?
    – Philip Shaw
    Nov 14 at 17:49












  • Use android tool: adb logcat
    – tito
    Nov 14 at 19:16















up vote
1
down vote

favorite












Im very new to kivy and python so I may have thrown myself in at the deep end here but i'm trying to figure out how to get an android intent and use it within a simple kivy app?



So im currently trying to figure out the basic design elements and just how to get stuff working. I want to be able to click on a link (for example) and launch my app and then do stuff, nothing too complicated, it just needs to be able to get the link which is passed to it from android.



I figured out this was to do with android intent filters and added the appropriate "intent_filters.xml" file to make this work.
So clicking on the link will launch my app, which is good.



However I cant figure out then how to parse the information passed to the app in android. So below is a very simple app with a button and I just want to update the button to see if my intent is being picked up or not.



Currently clicking the button causes the app to close. When i test this in the Kivy VM I am using to compile the apk it will close with a message that "platform" is not defined (which makes sense as its not in android) but it doesnt much help with testing or tracking down how to make it work.



I've read some stuff which seems to suggest that this might not be possible with kivy?
Can anyone confirm if this is possible in kivy and if so, how?
(i've tried variations on activity.getIntent(), intent.getData(), Intent.getIntent().getStringExtra(Intent.EXTRA_TEXT), Intent().getData().getPath() all to no avail)



from kivy.app import App

from kivy.uix.button import Button
from kivy.uix.boxlayout import BoxLayout


class TutorialApp(App):

def build(self):
self.gen_btn = Button(text='Initial',
size_hint=(.90, .10),
pos=(5, 5),
font_size=50)
self.gen_btn.bind(on_press=self.update_tutorialapp)
l = BoxLayout()
l.add_widget(self.gen_btn)
return l

def update_tutorialapp(self, *args):
st = update_button()
st.update_Message(self)

class update_button():

def update_Message(self, source):
source.gen_btn.text = "the event was called"
if platform=="android":
from jnius import cast
from jnius import autoclass
import android
import android.activity

# test for an intent passed to us
PythonActivity = autoclass('org.renpy.android.PythonActivity')
activity = PythonActivity.mActivity
intent = activity.getIntent()
intent_data = intent.getData()

source.gen_btn.text = PythonActivity.getIntent().getStringExtra(Intent.EXTRA_TEXT)

if __name__ == "__main__":
TutorialApp().run()









share|improve this question






















  • Hi, if your app crash, then please report the log associated to the crash. What does it tells you?
    – tito
    Nov 12 at 12:40










  • Well the only way I have to run it on Android currently is to copy it to my phone so I don't really get any messages when it crashes. If I enable logging/debugging when I create the APK would I be able to retrieve any useful information from a non rooted android phone (ie from the apps install directory within android)?
    – Philip Shaw
    Nov 14 at 17:49












  • Use android tool: adb logcat
    – tito
    Nov 14 at 19:16













up vote
1
down vote

favorite









up vote
1
down vote

favorite











Im very new to kivy and python so I may have thrown myself in at the deep end here but i'm trying to figure out how to get an android intent and use it within a simple kivy app?



So im currently trying to figure out the basic design elements and just how to get stuff working. I want to be able to click on a link (for example) and launch my app and then do stuff, nothing too complicated, it just needs to be able to get the link which is passed to it from android.



I figured out this was to do with android intent filters and added the appropriate "intent_filters.xml" file to make this work.
So clicking on the link will launch my app, which is good.



However I cant figure out then how to parse the information passed to the app in android. So below is a very simple app with a button and I just want to update the button to see if my intent is being picked up or not.



Currently clicking the button causes the app to close. When i test this in the Kivy VM I am using to compile the apk it will close with a message that "platform" is not defined (which makes sense as its not in android) but it doesnt much help with testing or tracking down how to make it work.



I've read some stuff which seems to suggest that this might not be possible with kivy?
Can anyone confirm if this is possible in kivy and if so, how?
(i've tried variations on activity.getIntent(), intent.getData(), Intent.getIntent().getStringExtra(Intent.EXTRA_TEXT), Intent().getData().getPath() all to no avail)



from kivy.app import App

from kivy.uix.button import Button
from kivy.uix.boxlayout import BoxLayout


class TutorialApp(App):

def build(self):
self.gen_btn = Button(text='Initial',
size_hint=(.90, .10),
pos=(5, 5),
font_size=50)
self.gen_btn.bind(on_press=self.update_tutorialapp)
l = BoxLayout()
l.add_widget(self.gen_btn)
return l

def update_tutorialapp(self, *args):
st = update_button()
st.update_Message(self)

class update_button():

def update_Message(self, source):
source.gen_btn.text = "the event was called"
if platform=="android":
from jnius import cast
from jnius import autoclass
import android
import android.activity

# test for an intent passed to us
PythonActivity = autoclass('org.renpy.android.PythonActivity')
activity = PythonActivity.mActivity
intent = activity.getIntent()
intent_data = intent.getData()

source.gen_btn.text = PythonActivity.getIntent().getStringExtra(Intent.EXTRA_TEXT)

if __name__ == "__main__":
TutorialApp().run()









share|improve this question













Im very new to kivy and python so I may have thrown myself in at the deep end here but i'm trying to figure out how to get an android intent and use it within a simple kivy app?



So im currently trying to figure out the basic design elements and just how to get stuff working. I want to be able to click on a link (for example) and launch my app and then do stuff, nothing too complicated, it just needs to be able to get the link which is passed to it from android.



I figured out this was to do with android intent filters and added the appropriate "intent_filters.xml" file to make this work.
So clicking on the link will launch my app, which is good.



However I cant figure out then how to parse the information passed to the app in android. So below is a very simple app with a button and I just want to update the button to see if my intent is being picked up or not.



Currently clicking the button causes the app to close. When i test this in the Kivy VM I am using to compile the apk it will close with a message that "platform" is not defined (which makes sense as its not in android) but it doesnt much help with testing or tracking down how to make it work.



I've read some stuff which seems to suggest that this might not be possible with kivy?
Can anyone confirm if this is possible in kivy and if so, how?
(i've tried variations on activity.getIntent(), intent.getData(), Intent.getIntent().getStringExtra(Intent.EXTRA_TEXT), Intent().getData().getPath() all to no avail)



from kivy.app import App

from kivy.uix.button import Button
from kivy.uix.boxlayout import BoxLayout


class TutorialApp(App):

def build(self):
self.gen_btn = Button(text='Initial',
size_hint=(.90, .10),
pos=(5, 5),
font_size=50)
self.gen_btn.bind(on_press=self.update_tutorialapp)
l = BoxLayout()
l.add_widget(self.gen_btn)
return l

def update_tutorialapp(self, *args):
st = update_button()
st.update_Message(self)

class update_button():

def update_Message(self, source):
source.gen_btn.text = "the event was called"
if platform=="android":
from jnius import cast
from jnius import autoclass
import android
import android.activity

# test for an intent passed to us
PythonActivity = autoclass('org.renpy.android.PythonActivity')
activity = PythonActivity.mActivity
intent = activity.getIntent()
intent_data = intent.getData()

source.gen_btn.text = PythonActivity.getIntent().getStringExtra(Intent.EXTRA_TEXT)

if __name__ == "__main__":
TutorialApp().run()






android python-2.7 kivy






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 11 at 14:13









Philip Shaw

62




62












  • Hi, if your app crash, then please report the log associated to the crash. What does it tells you?
    – tito
    Nov 12 at 12:40










  • Well the only way I have to run it on Android currently is to copy it to my phone so I don't really get any messages when it crashes. If I enable logging/debugging when I create the APK would I be able to retrieve any useful information from a non rooted android phone (ie from the apps install directory within android)?
    – Philip Shaw
    Nov 14 at 17:49












  • Use android tool: adb logcat
    – tito
    Nov 14 at 19:16


















  • Hi, if your app crash, then please report the log associated to the crash. What does it tells you?
    – tito
    Nov 12 at 12:40










  • Well the only way I have to run it on Android currently is to copy it to my phone so I don't really get any messages when it crashes. If I enable logging/debugging when I create the APK would I be able to retrieve any useful information from a non rooted android phone (ie from the apps install directory within android)?
    – Philip Shaw
    Nov 14 at 17:49












  • Use android tool: adb logcat
    – tito
    Nov 14 at 19:16
















Hi, if your app crash, then please report the log associated to the crash. What does it tells you?
– tito
Nov 12 at 12:40




Hi, if your app crash, then please report the log associated to the crash. What does it tells you?
– tito
Nov 12 at 12:40












Well the only way I have to run it on Android currently is to copy it to my phone so I don't really get any messages when it crashes. If I enable logging/debugging when I create the APK would I be able to retrieve any useful information from a non rooted android phone (ie from the apps install directory within android)?
– Philip Shaw
Nov 14 at 17:49






Well the only way I have to run it on Android currently is to copy it to my phone so I don't really get any messages when it crashes. If I enable logging/debugging when I create the APK would I be able to retrieve any useful information from a non rooted android phone (ie from the apps install directory within android)?
– Philip Shaw
Nov 14 at 17:49














Use android tool: adb logcat
– tito
Nov 14 at 19:16




Use android tool: adb logcat
– tito
Nov 14 at 19:16

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53249584%2fkivy-android-intent-filters%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53249584%2fkivy-android-intent-filters%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Full-time equivalent

Bicuculline

さくらももこ