phonegap jquerymobile : how to open external links via Android Browser - android

I am working on a project with PhoneGap and JqueryMobile in Android.
Now I need to open an external link via the Android Browser.
I just write
window.location.href("http://stackoverflow.com")
or
window.open("http://stackoverflow.com")
The App didn't reply at all?
Please tell me why and help me out. Thanks.

You need to use navigator.app.loadUrl('http://stackoverflow.com');
EDIT
Some code for PhoneGap always needs to be device-specific. What I do rather than device check is load a "platform" JS file which has code for each feature that has platform-specific code.
So you can create a function called openUrl which you define in each (Android, iOS, etc) project. In your index.html you just load the platform.js file using a relative path.
The implementation can then be platform-specific without ugly device checking.

Comment in phonegap config "res/xml/config.xml"
<access origin=".*" browserOnly="true"/>
by
<!--<access origin="*" browserOnly="true"/>-->
If you allow access, you allow website to be viewed in webview (in this case ALL website).
With no access, all external link are open in native browser.

Use this
window.open('http://www.myurl.nl', '_blank', 'location=yes');

Related

How to set up ssl ceritficate for react.cordova, ionic and android?

Help!
Im complete Beginner in developing apps for android or ios.
I started with ionic, react, cordova. I found nice tutorials how to set up ssl on angular but can not find something like that for react.
How can I set it up?
Is it in package.json or ...
The following article describe step by step how to configure ssl certificate.
https://developers.google.com/web/updates/2014/02/web-security-policy-changes-for-android-app-publish-apps#app_ssltls
I followed the steps and this is the answer:
Create a file called index.html in www and then add the following in the file.
<script src="https://js.ssl.google-analytics.com/burch.js"></script>
<script src="https://ssl.gstatic.com/android/gms_analytics.js"></script>
Important: in order to have the JS execution in the browser, you need to add the files in www directory.
If you are using an external server then just the following
This will get the Google analytics JS code to load.
If the JS code is not loading in your browser. Then it means that the server is blocking access from this external IP address.
Go to your server manager like aws, azure, google.
Then go to the server properties page and check this box.
Block access for unsafe protocols.
If the box is uncheck then the JS code in your browser will load in a second.

What's the approach of getting the web project into Android phonegap app?

I have a working web application. How would I refer to the index.html to this app's index.html?
super.loadUrl(“file:///android_asset/www/index.html”);
My web app already have the index.html. Do I just refer to that URL? Say my app is at:
www.myapp.com
Do I just type that address?
To quickly get it up and running put your index.html and any other html/images/css/javascript into zip file and upload to the PhoneGap build site. There's more to it that that but for a simple static app that will work.

How to load a web page in CordovaWebView for Android?

I'm trying to figure out how to open an external link inside a cordova web view without the "InAppBrowser" or system browser.
Initially I've tried to directly pass a link to the web view, blank page.
So I've put an iframe in a local html file, it only opens local files.
Then I tried to use:
window.open(myUrl, '_self');
He keeps opening this link in the "InAppBrowser", even if the whitelist doesn't exist, since I've put this:
<access origin="*"/>
in the config.xml file.
I have no more ideas. Please, give me some...
By the way I'm using the latest cordova.
I had to put this line before the initialization of the web view
Config.init(this);
They need to clear their code a little bit, or at least update their docs.
Use window.location.href=""
or
External Link.

PhoneGap on Android: Loading a WebApp from a remote server

My Android PhoneGap application works completelly as expected when I copy all the web files (html, JS, CSS...) to the www folder of the project, and compile the application with these files. But when I do not copy them, and make a redirection to my Web Server containing these files (i.e. in the WWW folder there is only one file: index.html with a redirection to my server) phonegap does not work in the application anymore.
Is there a way to get phonegap to work, when the application content files are delivered by a remote server and not compiled with the application?
It can be done. Nothing can prevent you from doing that.
Phonegap + Android :
In your main activity class, method onCreate change loadUrl to:
super.loadUrl("http://.../index.html");
iPhone + Phonegap ia another story, still it can be done. Because there's a lot of changes here's a tutorial: http://www.joeldare.com/wiki/open_a_url_in_phonegap
One more thing, you must enable internet connection for Phonegap.
As you are using the android platform add this line to your AndroidManifest:
<uses-permission android:name="android.permission.INTERNET" />
Ah, one more thing, a viewport meta tag must be set in your html file.

Use Phonegap ChildBrowser Plugin to view in App PDFs on Android

I have the childbrowser plugin installed and working on my Phonegap application. Works fine for websites but I want to instead view PDFs which have been stored in my assets file.
The link I have to the pdf is currently
Test
But when I do this it trys to navigate to
http://file://android_asset/pdf/Starting-Out_master.pdf
How can I change the link to view the prepackaged PDFs?
You cannot open a PDF using the ChildBrowser. You will need to use the PDF Viewer plugin. Here is a link, sorry that it is in Italian you'll have to use Google Translate or something similar.
http://www.giovesoft.com/2011/08/download-and-open-pdf-with-phonegap.html
Using the WebIntent plugin may also work. Most (but not all) Android phones come with a PDF viewer built-in, so letting the Android OS decide what application installed on the phone to handle the PDF file should work in most cases.
You could get the pdf file URI and open it with the childBrowser plugin's openExternal and let the native browser handle the PDF.

Categories

Resources