JQuery Mobile app generic doubts - android

I am new to JQuery mobile .
Need some assistance to start with.
My plan is for a mobile application( cross platform android and Iphone ) which will get and update data to a webservice. This will be a set of htmls. I need to access gallery and camera so i think it should be integrated with PhoneGap.
Now the html pages are hosted in same domain as web service. While
integrating to Phonegap would like to know whether i need to move
Html to app or keep the htmls in remote server and put a web view to
load html from there. Basically in samples i have seen the app itself
with htmls , so would like to know best strategy.
In Android app there is a hardware back button. Basically i have
a login page, home page and detail pages. While in Home page if hardware back
button is pressed , i should ask for logout . I searched but dint get
idea to handle the same.
May be i will remove camera functionality and then it will be pure
JQuery Mobile and no Phonegap. SO this will be loaded in browser
directly in device. So if in JQuery mobile only also , can this hardware back
button be handled.
Please guide me in right direction.
-Thanks in advance
mia

In reply to your first point: the practice of hosting the full html pages in a remote server is usually forbidden by the app stores (at least iOS having read the guidelines recently).
You should instead only retrieve data from the server (in the form of json/xml for instance). For this very purpose you can create your mobile app using Backbone, or any other MVC/MVVC platform.
Your base pages will be in the app -displayed by phonegap webview- along with some templates. Every time the user goes to another page, you fetch some json data from the server and then process your data with the templates to generate full html.
This process makes more sense than serving full html pages (which is then more a mobile site than a mobile app) as only the data (what is dynamic) is sent from the server, which makes the payload smaller (better for mobile devices with limited bandwidth capabilities).
For the second point, I guess you mean when the app is closed or put in the background through this back button you want to call a logout function in your app. You'll need to catch a system event, but that's not something you can handle directly in Phonegap and you'll need some native java coding for that.. but first check the phonegap plugins for such feature but I haven't seen any.
For the third point, if you say you don't want to use phonegap your 'mobile app' will become only a 'mobile site'. which is fine, but then you'll have even less control over that "back button". You'll only be able to control web events like window close (beforeunload).

It is possible to have the full HTML on the server and I have had an app approved for the iOS app store with this method. However there are obvious downsides including the fact that you lose off-line capabilities.
You can add an event listener for the back button document.addEventListener('backbutton', onBackButton, false);
As far as I know you cannot handle the back button with a mobile site.

Related

Inject or load html file into TWA/Custom tabs

I'm currently working on a TWA / Custom tabs application. Seeing as the user needs to load a website, I want to implement an offline page incase the user isn't connected to the internet.
When using a webview, I can just load an html file, with custom tabs it seems to be more difficult.
What I'm currently doing: Once the app is launched, I do a check to see if the user is connected to the internet, if that fails I would like to display my offline page and give them the option to retry, otherwise start the custom tabs intent.
Is there an easy way to load/inject my offline html page into the custom tab, or is there another way to load the html file into view?
The best way to implement an offline page for your web application is to use a Service Worker.
An advantage of this approach is that this offline page will also work for users using standalone browsers. And, by adding a Web Manifest, your application will become a Progressive Web App and will be installable from the browsers.
Service Workers can be a complex subject, so I'd recommend using WorkBox to get started with it. Here's a recipe for a simple offline page.
There's one caveat with this approach - the Service Worker is installed when the application is used for the first time. From that moment onwards, it will show the offline page if the user opens the app while offline. But, if the user is offline the first time the application is opened, they may still see the offline dinosaur. There's an open issue to improve this at https://crbug.com/816798.

Control a webpage trough python or any other programming language

I want to build a videomapping which you control with an Android device.
Say, I have a webpage that is totally black, and then on the Android device, I have a WebView app which has a few buttons. Every time I click on one of those buttons, that should trigger an event in the webpage, like showing some shapes or switch colors.
I know how to write an Android app with python sl4a alongside with HTML, CSS and JS. My question is, how can I broadcast these events to a webpage, making it trigger those effects when I click on a button on the Android side, using Python or another language.
First of all, you can not trigger an event directly in a web page from any android app. What you can do, however, is from the android app store the changes into some backend storage (or server). Then the webpage can have a auto refresh, and see changes related to the backend storage (or server).
Another version of getting this kind of communication is to set up message queues. Then you would setup that the android app is pushing messages, and the webpages sets up a listener and reads messages from the queue. It can then react to the messages.
Unfortunately, I don't currently now what kind of message queues are available for android, python, ..., so you have to do a little research there. You also need to know if that message queue is somehow supported by your webpage, either in javascript or some serverside scripting of that webpage.
Hope this is enough information to get you going!

How to text a download link to iPhone or Android Device

We are creating a landing page of sorts for our iPhone/Android app and on this page there will be a link to each of the respective app stores. However, when the user is on a computer, it's a bit cumbersome to access the app stores (particularly Apple's app store). So we would like to add a "send text message to phone" feature like Groupon does on http://www.groupon.com/mobile.
Now, my questions with this are as follows:
A) What sort of code do I need to put in to make this feature work? Is this super intensive or are there free or cheap options available out there to do this for me?
B) How does the code know whether it is an iPhone or Android that it's texting? Groupon took me immediately to the Apple store on it's link. Tried going through the source code on Groupon but it was a bit beyond my grasp.
Thanks for any help!
A few different things are needed to get this up and running:
You should use something like Twilio to programmatically send text messages
You need a page on your server (say http://mydomain.com/app_redirect) that sniffs user agents and then redirects the user to either the iOS AppStore or Android store respectively
Once you have those pieces it's fairly simple
Create landing page like groupons
When the user posts their cell phone to your server call Twilio to send out a text message containing the link http://mydomain.com/app_redirect
When user taps the link it will open a webview, which will then redirect to the correct appstore url depending on the device

Selenium, WebDriver, HtmlUnit equivalent for android

This is what I'm trying to do:
1. I have a tablet and I want to connect to the university's wi-fi to access internet
2. Connection to the internet won't work unless you open a browse
3. You are automatically redirected to a university username-password page
4. You type in your university credentials and boom => you have internet
Problem??? I hate to have to put my password every single day and although chrome for android can store it I still have to open a browser, etc. etc. etc.
Solution:
Use Selenium, WebDriver, HtmlUnit or some sort of headless browser to programmatically fill in the login form in the background.
Problem 2: These headless browsers don't work on Android (Or I haven't been able to make them work)
Does anyone know of a simple headless browser that works on Android devices, one that can fill a simple form and submit it? Are there other alternatives to what I want to do?
Thx in advance for the help.
Some related Questions: HttpUnit/HtmlUnit equivalent for android, Android: Fill Form Data and Extract HTML, Html Parsing in android
How does the University validate you once you've logged in? e.g. is it based on setting cookies in your web browser? What happens if you login with another web browser once you've authenticated in the first one?
Once you know how it authenticates you, you should be able to devise a suitable approach. For instance, if it's device-wide authentication e.g. based on your mac address then perhaps you can write a simple Android app that embeds a WebView, and/or plain old HTTP request / response programming in Java. If, however, it's browser based then you either need to login (automagically) with the browser you then want to use, or find a way to insert the relevant cookie(s) into the browser that you want to use for web browsing.

Android App - Log into site WITHOUT authentication?

I am working on an Android login app for a service called Netclassroom. There are many for different schools (you can google for one), but I'd prefer not to share the one I'm working on. They're all the same. I want the app to log into the site using given credentials, but I'm running into a problem.
The problem is that it "does not use authentication" and the post request doesn't work? Is it even possible to log into a site like this? By that I mean that I want to enter credentials and get to the member page to parse.
You can make an app that just starts the browser on a particular URL. Here's a post that describes how to do it,
How can I open a URL in Android's web browser from my application?
Further, I think you are asking if the app can circumvent the normal web page login mechanism. Don't do that. There's a login on the web page for a reason. If your app gets around that, then it's decreasing the security that the folks that designed the web page put in place. The correct thing to do is to work with the folks that wrote the website. If they think what you are doing is acceptable, they should make their login cookie longer-lived, or allow the user / pass fields to be stored in the browser, etc.
Again, there's absolutely no rational for making the android app less secure than the browser app.

Categories

Resources