Developing in Android with Python 2.7 - android

I want to develop a Android app using Python 2.7.
I read about it online but I couldn't find good answers, I saw Kivy. But I also saw a way to develop python via google.
I want to show a webpage (not sure if its going to be online or offline), in a app, without the user having to download anything except the app.
I saw Webview, but I coulnd't find how to implement it.
In short:
How do I develop a android app that shows a webpage with python 2.7, without the user having to download anything except the app.

You can create a Kivy app that displays and manages a webview using something like https://github.com/kivy/kivy/wiki/Android-native-embedded-browser, though this requires some interaction with the java api (done via python as in the link) because we don't have a way to stream the webview content to a kivy widget.
A webview-only app is something kivy is not that well suited for, you might be better off learning to make a normal java app.

Related

How can i build native android apps from any website (Not Website convert into apps)

Suppose , i have a website and its running well . Now i want to make an android apps using website information or My apps will contain all the information of that website already contain or how can i connect an android apps with any website.
Some solution :
1. convert website into android apps (i don't need this).
2. JSON API (i think this is best option for me ).
May be there has so many option but this time i can't remember. option is best for me if it is possible . but i don't how to create a JSON API from website .
but i don't know how to do it. please let me know share something for better understand.
or if has any other better solution for this problem please let me know .
You could create a web app, using android native web view or some technologies like ionic, etc..., or create a comprehensive API endpoint in your backend/website and start build an android app from scratch.
creating a web app is a simpler approach but has so many shortcomings in design, functioning and flexibility aspect, so if you want a competitive app with a fine extendibility feature the best option is native android development. but it could be more costly as it needs both backend and android development.
If your website is already implemented and running, you can just create an Application using a https://developer.android.com/reference/android/webkit/WebView. Basically, this is an injected Browser, allowing the user to access your Website without actually open chrome/firefox etc. on the smartphone.
To improve the usability, the layout of your website should be able to dynamically resize the content.
If you wish to actually implement an application (Activities/Fragmets...) you need to connect to your backend server the same way your website is retrieving the information.

How to create an APK of a HTML5 to run on Android

I know that those kind of questions have been asked before, but I couldn't find a topic to help me.
I have been give a HTML5 game and I was asked to verify if I can run it on an Android tablet.
I'm a little bit confused with what I have to do? Should I create an Android project and import the file or is there an easier way to create an apk?
Thanks for your help.
You could look at Apache Cordova. This is a powerful environment made to support app development in HTML5. As such you should be able to literally copy your game resources over, run a build and have a full fledge Android App. Fun fact, provided you have access to OS X, Cordova will produce an iOS compatible app too.
If your game consists of HTML, CSS and JavaScript, such that it can be run off a modern web browser with no special plugins installed, rest assured it can run in an Android tablet.
You could access it directly from the tablet's browser or you can make an app (packaged in an APK and installed from it) which does essentially the same, but with a great benefit: the web page and the app can communicate (via JavaScript), enabling a richer experience.
Example of such communication: you're making an app for a web forum, and the link for "compose new message" opens an Android activity for writing that POSTs the result to the server, instead of constraining you to write in a small web browser form.
For more information on the subject, check out Android API Guides for Web Apps.

combining html front-end and python "back-end" in mobile app

My application has an html-based front-end and uses python logic on the back-end. This application needs to run offline, not connected to the internet, so by "back-end" here I don't mean a server running remotely, but rather python logic running side-by-side in the same app as the browser/html engine. For Windows or Mac desktop apps, I build a Chromium Embedded Framework application, and then launch a sub-process which runs a CherryPy python application built using py2exe (or py2app). The client and the server then communicate using normal http.
I'd like to achieve the same thing on both iOS and Android. I've researched several alternatives, but nothing seems to do quite what I need.
Kivy is close, but as far as I can tell it doesn't offer a browser/html front-end, but rather provides its own layout engine on top of OpenGL. It has an extension mechanism, but that seems to be more about extending the python side, not the front-end side.
On the other hand, I could start with PhoneGap and then add a python library as an extension (possibly using Kivy's mobile library build of python). Or for that matter I could just write a regular C++ app that embeds a browser and uses a python library build.
On the third hand, I've played with using various python-to-javascript converters to get the back-end logic into something that can work with PhoneGap directly, but that approach gets pretty difficult given all of the python logic I have -- some of it just doesn't convert so easily.
Do you know of apps that are displaying html and running python logic in the same app?
You could do a very simple kivy app, that would start a service (inside which you would do your "server" side, with a small engine like flask or bottle, but i guess cherryPy should work too), and in the main.py of the "kivy" app, don't import kivy, just import webbrowser and start a browser window to localhost:your port. This will use the android browser.
edit: oh, services are android only for now, apparently ios 7 supports them too, but kivy-ios hasn't been updated to make use of them.

integrate matplotlib into android app?

I've been playing for some time with python and matplotlib and managed to create some neat desktop applications. [like graphical analysis tool for linear algebra, rendering engine for maps etc.
I was wondering if I could turn these applications into android apps. I'am completely new to android. I plan to use python (though I'm good with java) for the coding (I know this is possible with tools such as kivy or SL4P).
I want to know the limitations for using these tools in android. Can I even get matplotlib into android? I searched everywhere, but couldn't find how to go about a matplotlib based android app.
Any kind of pointers would be helpful.
I doubt you can embed matplotlib on an Android device (or any other kind of smartphone or tablet).
One alternative possibility would be to make your app connect to a back-end server that has matplotlib, and use that to generate the figures and send back images to the client.
Advantage: Can potentially get a working mobile prototype finished somewhat quickly by reusing existing code.
Disadvantage: The app cannot work offline since it relies on your central server.
Matplotlib cannot be compiled for android, numpy can though:
https://code.google.com/p/android-scripting/issues/detail?id=260

Writing and deploying Android app

So I want to make an app to scrape random inspirational quotes from a website, then show me them on my Android phone. What steps do I need to do this? Preferably I'd be able to do it in Clojure... if not that, then Ruby, if all else fails Java.
What do I need to do to write the app and importantly, to deploy it?
Hm, that's a very general questions with not a lot of info, but here are some random pointers for different parts of our question:
Enlinve: Scraping with Clojure
An Enlive tutorial
Screen Scraping with ScrAPI: A screencast on scraping in Ruby
Mechanize for scraping in Ruby (Nokogiri and Hpricot could also work)
Rhodes for Android development with Ruby
An Android application is developed in Java. You can also solely use C++ in the most recent version, but I think that's not what you're looking for. There are, however, a few hacks you can use to write less Java.
Are you familiar with Mirah? Mirah looks a lot like Ruby but it's statically typed. You can use Mirah to develop Android applications. Have a look.
You can also use Ruby, by taking advantage of the JVM (JRuby). Daniel Jackoway developed Ruboto in last years' Ruby Summer of Code. Ruboto allows you to develop Android applications in Ruby. Have a look.
Concerning site scrapping, one option is to use Nokogiri as Michael mentioned. It'll work in both Ruby and Java, but in the latter you'll have to hack a bit — not everything is currently working. There are a lot of HTML parsers for Java as well, namely HTMLparser or JerichoHTML.
Android applications are officially developed in Java/C++ but, as you can see, there are other options. Don't forget to take into consideration that by choosing these other options you won't be able to take advantage of the Android SDK.
The path of least resistance on Android would be Java. The app works basically like any other "screen scraper": pull the page, parse it, and display the information. How easily it is to parse will depend on how well structured the content is on the original site. If it happens to have an RSS feed you can probably use one of the many open-source Java RSS Parsers.
If you already have a server side program to acheive this, you can create a webview activity in android to show the same. So you can create your server side program in a language of your choice.
For me phase 1 would be to write a web app and access it using the Android web browser. You can use a JavaScript library such as jqTouch to make the web app look just like a native Android app, and you can access the geolocation api from the browser using HTML5.
I've built an iPhone app demo using this approach with compojure on the server and deployed to google app engine. It worked well.
Cheers,
Colin

Categories

Resources