Android how to join android app with a kodi addon
#1
Realization of an Android-App + Kodi Addon (running on a Linux-Machine) + PHP-Script.
(see attachment)
1- The App sends a message (e.g. "Kodi") to the Addon.
2- The Addon starts another PHP-Script and forwards the message to it.
3- The PHP-Script responses with "Hello Kodi".
4- The Android-App shows then the Response from Kodi.Image
Reply
#2
Welcome to the Kodi forums.

I don't know the better option to achieve this but if I were you I would have a look the webinterface addons ( http://kodi.wiki/view/web_interface ). You can plug python logic to Kodi's HTTP web server through WSGI. This allows you to build webinterface addons that take advantage of any web development framework compatible with WSGI (for instance, Flask).

You can then execute your logic there. Look here for an example of a Flask web interface addon: https://github.com/tamland/kodi-flask-demo . Also have a read at the PR that enabled that in kodi https://github.com/xbmc/xbmc/pull/6453


You can then simple create something as easy as:

Code:
from flask import Flask

app = Flask(__name__)

@app.route('/')
def index():
    return "Index"

@app.route('/android')
def hello():
    return "Hello Android!"

if __name__ == '__main__':
    app.run()

That way, when you access http://YOUR_KODI_DEVICE_IP:PORT/android Kodi will return the string "Hello Android!. You can do all sort of fun things in between. Also, if you don't want to loose the original webinterface you can simply copy the static (html/js/css) files to your new webinterface plugin. Then on the index route you simply make flask to render a template or to serve a static file (Read docs for more info: http://flask.pocoo.org/docs/0.12/quickst...atic-files). Smile

Hope it helps
Reply
#3
I agree. Since Kodi has embedded Python runtime, it's better to use Python-based web/REST apps rather than PHP. Honestly, I don't even know how to run PHP from Kodi.

Flask is a solid choice but personally I prefer Bottle. It has API similar to Flask but it is self-contained and does not have external dependencies. And it's included in the official Kodi repo as script.module.bottle addon. Also IMO Bottle better handles JSON data, so a REST API based on Bottle is less verbose.

Kodi has its own WSGI server but for non-critical tasks you can also use WSGIref server from Python standard library. It can co-exist with Kodi web-interface as long as it runs on a different port.

If you decide to run your own server, then your addon must be of service type.
Reply
#4
In libreelec/openelec it is quite easy to setup a lamp server. There is an addon for that, at least for arm devices:

https://forum.libreelec.tv/thread-280.html

But I agree with roman, do it in python Smile

Enviado do meu A0001 através de Tapatalk
Reply
#5
will someone of you can help me to implement this project i mean i am very new to kodi development i want someone who know a quite a bit about how to create addons my email is [email protected] any one from you can link me to do this task. I am very thankful to you all for this help..
Reply

Logout Mark Read Team Forum Stats Members Help
how to join android app with a kodi addon0