You create your application mobile friendly
for kivy
After installation kivy :
you create main.py
and you paste this code there are others codes but it's just an example :
import kivy
from kivy.app import App
from kivy.lang import Builder
from kivy.utils import platform
from
kivy.uix.widget import Widget
from kivy.clock import Clock
from jnius import autoclass
from android.runnable import
run_on_ui_thread
WebView = autoclass('android.webkit.WebView')
WebViewClient = autoclass('android.webkit.WebViewClient')
activity = autoclass('org.renpy.android.PythonActivity').mActivity
class Wv(Widget):
def __init__(self, **kwargs):
super(Wv, self).__init__(**kwargs)
Clock.schedule_once(self.create_webview, 0)
@run_on_ui_thread
def create_webview(self, *args):
webview = WebView(activity)
webview.getSettings().setJavaScriptEnabled(True)
wvc = WebViewClient();
webview.setWebViewClient(wvc);
activity.setContentView(webview)
webview.loadUrl('http://www.google.com')
class ServiceApp(App):
def build(self):
return Wv()
def on_start(self):
return True
def on_pause(self):
return True
def on_resume(self):
pass
def on_stop(self):
pass
if __name__ == '__main__':
ServiceApp().run()
on line webview.loadUrl('http://www.google.com') you put url from your
webapplication
then you can compile for android for example. there are others methods for
windows phone and iphone
you can read the kivy documentation and kivy google groups or kivy github.
for cordova:
After you install you do that :
# go into your projectcd myapp# create a mobileapp folder for your app
cordova create mobileapp com.whatever.appname AppNamecd mobileapp# add android
cordova platform add android# compile the app
cordova build# now, plug in your testing device, and let's run our test app on
it
cordova run android# if you don't have a device handy you can use an emulator
(much slower)## cordova emulate android
# install plugins for alerts and network information# used to alert the user if
they are not connected to the internet
cordova plugin add
https://git-wip-us.apache.org/repos/asf/cordova-plugin-dialogs.git
cordova plugin add
https://git-wip-us.apache.org/repos/asf/cordova-plugin-network-information.git
then you go to then the forlder www/index.html your paste this code
<!doctype html><html lang="en"><head>
<title>Zoggle</title>
<script type="text/javascript" charset="utf-8" src="cordova.js"></script>
<script>
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
//navigator.splashscreen.hide();
if (navigator.network.connection.type == Connection.NONE) {
networkError()
} else {
loadApp()
}
}
function loadApp() {
navigator.app.loadUrl("http://www.web2py.com")
}
function networkError() {
navigator.notification.alert('web2py requires an internet connection')
var $net = document.createElement('div')
$net.innerHTML = 'web2py requires an internet connection'
document.body.appendChild($net)
}
</script>
<style>
body {
padding: 15px;
background: #23252e;
color: #01ced3;
text-align: center;
}
div {
font-size: 20px;
}
</style></head><body></body></html>
on this line navigator.app.loadUrl("http://www.web2py.com") you put your
url web application.
look this link for for better explanation
https://zolmeister.com/2014/01/how-to-turn-webapp-into-native-android.html
Le mercredi 27 janvier 2016 16:48:00 UTC+1, Ron Chatterjee a écrit :
> Any documentation of using Cordova or Kivy using a hosted web2py app? If
> a site is hosted using bootstrap3 and html5 its mobile friendly anyway.
>
> On Tuesday, January 12, 2016 at 9:12:01 AM UTC-5, eric cuver wrote:
>>
>> you can also do this with web2py you just need to create a webview with
>> Cordova or Kivy with the URL of your mobile website view. Me this is what I
>> do and it works without problems
>>
>> Le lundi 11 janvier 2016 22:31:58 UTC+1, Alessio Varalta a écrit :
>>>
>>> Sorry, , you are right. Now i have developed only in Android now in
>>> these day for a project i start to study cordova and is true that you can
>>> upload on Google market this my first time with Hybrid app
>>>
>>> Il giorno lunedì 11 gennaio 2016 13:17:14 UTC+1, Andrew Buchan ha
>>> scritto:
>>>>
>>>> Just to butt-in on what Richard said:
>>>>
>>>> "But this kind of app are often not that interresting from user stand
>>>> point... I mean you don't have a good mobile app user experience with them
>>>> most of the time because they to simple that you can just access the real
>>>> web app and it could be even better..."
>>>>
>>>> That's not really true anymore...
>>>>
>>>> What you are referring to are hybrid apps, which is essentially a
>>>> mini-website (HTML, JS, CSS) wrapped in a package and rendered in a native
>>>> webview, as opposed to a native app which is built in objective-C or Java.
>>>> Hybrid apps can access the phone's features such as camera, battery,
>>>> geolocation, accelerometer etc... So you can do much more than you would
>>>> by
>>>> accessing a web app in the browser!
>>>> Hybrid performance is also more than adequate for most applications,
>>>> and many of today's top apps are hybrid (in fact I challenge you to find
>>>> out which apps on your phone are hybrid and which are native...)
>>>>
>>>> What's more, with tools like cordova you can target both Android and
>>>> iOS (with caveats) with the same code.
>>>> You also get to use the latest Javascript frameworks, such as AngularJS
>>>> or ReactJS.
>>>>
>>>> My advice would be to learn js and angular then go down the ionic (
>>>> http://ionicframework.com/) path. I really don't see a case for
>>>> bringing web2py into android.
>>>>
>>>> Edit:
>>>>
>>>> What Alessio said isn't true either. You can publish hybrid apps to
>>>> Google play and Apple's app store.
>>>>
>>>> Here's a useful page:
>>>>
>>>>
>>>> http://www.joshmorony.com/the-step-by-step-guide-to-publishing-a-html5-mobile-application-on-app-stores/
>>>>
>>>>
>>>>
>>>> On Monday, January 4, 2016 at 9:20:53 PM UTC, RAGHIB R wrote:
>>>>>
>>>>>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.