I need to create a HTML page with will interact with Sqlite database. This page and database will reside on an android device. This HTML page will be accessed by devices(PCs) connected to this android device locally. Since I have .NET background with no experience in Sqlite Or android etc, I am clueless as to what technology/language I will have to use. C# won't work I suppose.
Any suggestions? How do I go about it?
You can use the following tools/libraries to achieve what you want:
NanoHTTPD Server: A lightweight HTTP server for Android. You can read more about it on the Github project page. You can either use the bare server and add features like routing, etc. on top of it or use the Nanolets class provided by NanoHTTPD. There isn't much documentation around Nanolets but they are more-or-less like servlets for Android. To know more about them checkout this test file.
Room Persistence library: Room is a lightweight orm for SQLite developed by Google and is a part of the Android Architecture Components library. It abstracts away lots of boilerplate code you would have to otherwise write when using SQLite on Android.
Although, if you are just getting started on Android or are otherwise learning Android I would still recommend bare SQLite framework shipped with Android to know what is actually going on under the hood.
Using the above mentioned libraries, you can create a server on your device that can serve your requests. I would recommend that you develop a REST-like API for your service and interact with the API from JavaScript in the browser running on the PC.
You can use any JavaScript frameworks like Angular, React, Vue or even jQuery to build a single page front-end application to your service, bundle the JavaScript in a single package (using something like webpack) and ship the resulting bundle alongwith your Android app (preferably inside the /resources or /assets directory). You can the serve the bundle from Android device whenever another device connects to it, and then use the API to handle business logic.
Related
I have no idea how does applications like Amazon, Flipkart etc work. They have both android application and website. How does data between both web and Android synchronise?
Do we write separate codes for building android app and website? If yes then in what language we build the website so that it's compatible with the android application.
And how to build the database for the same.
If answer is no to the above question, then how exactly do we proceed to build such Android and web application.
I am new to this and want to learn how to build it.
In general, web sites are built with web technologies such as JavaScript, HTML, and CSS, but there a many different frameworks and libraries in other languages (such as Angular, which is written in TypeScript) that can also handle the creation of web apps. In comparison, mobile applications for Android and iOS are written it Java/Kotlin or C#/Swift, respectively. There isn't really a clean, native way to create a single app for web and mobile platforms. But, the data that backs both of the platforms is the same.
How does this work? The data is hosted on what is called a backend, a server that has the information that you want to display to your users. Typically, the client app can get this information with an HTTP request to the backend, and the response will be the data formatted in a JSON string. Data is stored in the backend in a database. There are many databases in use today, but some more popular ones are MySQL, MongoDB, and SQLite, and each of them have their advantages and disadvantages. As you get further along in your development cycle, you will need to choose the tools that work for you.
Websites (and relative applications) like Amazon have very complicated systems behind what you see on the screen. Of course they have different code for either application and website. Usually, in small projects, you can create the mobile android app with languages like Java or Kotlin and websites with html, css and Javascript. But when it comes to get together data between an app and a website, you will need to write backend software, which is not so easy, for example in php and then create a database to store the data (with mySQL for example). Then you can access your data from either app and website and decide what to do with it. I suggest you to learn one of these technologies at a time. Trying to learn them all together will only create misunderstandings.
Hope I've been useful.
I have an application that runs on Android phone. I would like to add web ui like let's say torrent applications. I would like to manage my application from browser using my laptop, or another phone located on a different side of the planet ;)
What is the easiest way to run a web server inside app, and host a management web app? Is it possible to run nodejs/php server inside application and communicate with hosted web app?
Should be possible, because ttorrent and x-plore have such feature.
Thanks for any clues and advices.
I did several in-app web server projects. nanohttpd and golang are used in my projects.
Nanohttpd is wrote in pure Android SDK compatible Java. You can call any Android SDK API, with no need of RPC or language binding. But nanohttpd has little supports to develop web API. It's not a good choice if you have lots of APIs between javascript and the in-app server, but good if you need invoke Android SDK APIs in the in-app server.
golang supports Android(ARM Linux) well. The good parts are:
static link. you just need coding and build, everything will in one shared library file, you can ease use the library in your Android project
powerful APIs in standard library to develop a web server and web client. Great performance because of golang's async I/O and thread model
gomobile provide a tool to generate RPC wrapper for golang-java inter-operation. golang-c(jni)-java wrapper will also work but I not found a tool to generate the binding, writing bindings is boring.
I want to built a mobile application using Phonegap that will communicate with the restful web services and parse the json data.There are two ways two do it:
Calling restful web services using http connection in Java and connecting the Java code to JavaScript file by making our own plug-in in cordova.
2.Making ajax calls to communicate with rest services.
Which one is better considering the needs below:
1.It can call https web service,since for https in android we need to include certificates,create bks file for that which includes lot of mess.
2.It should be able to receive and parse the json data and render it to the html page.
3.We need to built this app for primarily android OS but if we can built it for ios,windows etc. It would be better.
Please tell me if i am using right tool,if sencha touch is easier to perform these tasks?
I would suggest that you use AJAX because it completely fits all your needs, and you gain to use the same code for future use if you'll ever decide to build for more platforms.
moreover, why make things complicated? you already writing your app using javascript, so don't mix it with native code when its unnecessary.
The fact that you choose PhoneGap, it is an indication that you are wanting to re-use your HTML/JS/CSS expertise as much as possible. Say if you choose jQuery Mobile (or any other framework) for your project, jquery provides ajax for your needs already and there is no reason to go down to the JAVA layer.
That said, the right approach should be using the ajax mechanism provided by your javascript framework. This is your option-2 and you won't need to build the raw ajax utilizes. Like if you go with jQuery/jQueryMobile + Backbone + backbone.marionette (we happen to use them in phoneGap app), there are a lot of add-ons out there to help. Like in this example, it is actually part of the phoneGap app under 'www' directory.
Also the communication to the webservice is your least concern if you have all the tools. Making suggestion on what tools to use is not allowed by Stackoverflow:-)
I am using Backbone.js to build a 'hybrid' web app, which will be served as a native app using Phonegap. One thing I need is offline support for a large amount of data, and so we are considering using native code to synchronise the offline data with the server, and just transfer the bits of data we need to the web app when necessary. (An alternative approach we considered was using the Phonegap storage plugin but this is backed by WebSQL which seems to have a 5MB quota, which is too small for what we need).
As the app is based on Backbone.js, which expects a RESTful API as its backend, we are toying with the idea of embedding a RoutingHTTPServer into the native layer - essentially this allows us to embed a local web server in the app, so that the web layer can request data using standard RESTful calls to the local server. The beauty here is that the Backbone app doesn't know any different - the workflow is entirely the same as requesting data from a remote server.
I was wondering if there is an equivalent of RoutingHTTPServer for Android? I have seen projects like iJetty, but ideally I would like something which gives the REST-API bit out of the box too (like RoutingHTTPServer does). Would something like Spark work on Android?
Try MiniWeb Java Embedded Webserver. It is built for Android, super easy to setup JSON REST requests and open source.
I'm working on a HTML5 cross-platform Survey application using jquery mobile, phoneGap , and sqlite database with web Storage !!!!
For Now I'm testing this App on Android Plateform using eclipse .
I'm new to the mobile world , I'm more familiar with j2ee web applications
So i'm wondering what can we call this type of architecture especially that I'm not working with a real server such glassFish ,TomCat .. or even a real SGBD and that everything is on the web browser (I'm using chrome)
Could Any one Help me with this ?
thank u :)
Here is the list of possible styles of architecture but I can't find the suitable one for my case !!!
You're building HTML5 loader apps on multiple platforms, depending on if you are storing your HTML5 locally or pulling it off a server, that's your answer for Server/Client.
You'll want object orient your javascript so you don't pollute the namespace. If you are scripting on the backend, also a good practise... I think object oriented goes without saying these days.
You can tier out your javascript to have a frontend generator, business logic layer, and data layer to handle your transactions with sqlite. Or you could also follow a MVC tiered setup.
If you are pushing data from the device to a central repository (which I think you must), you could build SOA on the server to handle the ingestion of data.