Android Cordova WebView - android

I am new to Cordova android development.
I want to open the specified URLs within the application instead of opening up it in browser.
I know I have to use WebView but I need help for how to use the WebView.
How to implement Cordova WebView for cordova android application?

We don't need to take an any external webview. Your complete cordova app will run by default in webview and URL directly will load into webview.
To redirect URL use,
location.href = "pageName.html";
OR
load page like
<iframe src="http://www.google.com"></iframe>

Related

Android webview from angularJS website. Not able to get redirect url

I have a website built using angularJS. Now I want to make an Android application using webview and some native code. So I want to get all redirect urls on click of anything in website, so that i can judge whether it to be loaded using angular or native. Since angular is doing internal routing I'm not able to get url using shouldoverrideUrlLoading from Andfroid.
Can someone please give a workaround. Or please help me in transferring data from angular to Android using javascriptInterface
You cannot transfer data directly from Angular to Android as angular is used at the client side of the application.
Why not use the same Rest API which if you are using and consuming in Angular Application. Use the same API in Android to get the data.
So, Basically the interaction of data should happen between your webserver API and Android.
If you just want to see the html page in android on click of that href link. Use WebView widget in android.
webView = (WebView) findViewById(R.id.webView1);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("http://www.google.com");
You can read more about it in developers doc..
http://developer.android.com/reference/android/webkit/WebView.html

Phonegap - Create new app for hosted web app using it's URL address

Hello everyone. I need some help please for developing the app with
Phonegap for multiply platforms.
I've got a task which is to create the app for android/ios/windows
with phonegap from the existing responsive and hosted web application.
I was provided only with website URL address. No project files been provided (index.html, css, js, etc,).
My question is it possible to do that, only having website URL
address create the application that by opening that application user
would be redirected to that URL address?
I'm new to app development. Any ideas how to achieve this would be appreciated.
You can simply load the webpage inside the phonegap's webview.
When you create a new phonegap/cordova project it'll contain sample web project. You can go to index.js and within 'deviceready' function you do the loaging.
Simplest way to do that is by just redirecting the webview to the remote resources you've been given:
document.location="http://your.url";
it'll load the url that you've been given inside the webview.
Have in mind that this is a lame approach.
This article explains how it should be done: https://www.ibm.com/developerworks/mydeveloperworks/blogs/94e7fded-7162-445e-8ceb-97a2140866a9/entry/dynamic_page_loading_for_phonegap1?lang=en
Good luck.

How to open an article in android app?

Can someone tell me what steps to follow to open an article in android app?
I do not meant open via browser but in-app.
Update description:
I do not mean open the actual website article, but copy the content (along with images, video links) and show it in the app with your preferred font, background etc
You can open a web page in-app (instead of the browser) by using a WebView (see documentation here). I recommend also reading the API guide topic Building Web Apps in WebView.
you may use webview to load your html file
WebView webView = (WebView)findViewById(R.id.webView1);
webview.loadUrl("file:///android_asset/file.html");

XDK - open link in browser without using Cordova

I want you to open a link in my app via browser not in Appview. I ma making my html5 mobile app via xdk. I don't want to use cordova in my app as my app is heavy enogh and don't want to make it heavier because of just one link.
I saw this :
www.kidzout.com
But the problem is I must install Cordova InAppBrowser plugin for this to work. Do you have any solution without using Cordova or external plugins? Do you think is it possible at all?
You can open a link in the native browser(Mobile Safari, Android, etc.) from within a HTML5 Mobile app using the intel.xdk API formerly AppMobi.
In the head, include a reference to the intelxdk.js file.
<script src="intelxdk.js"></script>
Use this for opening your link:
Launch in Browser
For more information, go to http://www.html5dev-software.intel.com/documentation/jsAPI/device/launchExternal/index.html
If you are opening a remote URL in your webview and adding javascript is not an option, you can make a patch in native code.
Here I show the workaround for Android:
https://stackoverflow.com/a/35037737/813951

Phonegap Android: Load local html from hosted application

At startup, my Phonegap application loads a hosted application (cordova is loaded from there). In certain cases (events) I want to redirect the user to an html file that lives in the phone.
Is there a way to accomplish that?
I've tried redirecting to file:///android_asset/www/index.html but doesn't seems to work.
Maybe a PhoneGap plugin that exposes Android's loadUrl() to JavaScript?
EDIT: I'm using Phonegap 2.8
You can use navigator.app.loadUrl:
navigator.app.loadUrl("file:///android_asset/www/index.html");

Categories

Resources