phonegap android: opening another html file in the phonegap webview - android

i am building a phonegap(v1.3) android(for 3.1 sdk) app. i load the index.html page as in the sample app
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.setIntegerProperty("loadUrlTimeoutValue", 60000);
super.loadUrl("file:///android_asset/www/index.html");
}
this works fine. now later on i want to load another abc.html file in the webview when i call for it from the js through a plugin. How to achieve a function like this which we can call from a Phonegap plugin.
public void loadUrl(String file){
super.setIntegerProperty("loadUrlTimeoutValue", 60000);
super.loadUrl("file:///android_asset/www/"+file+".html");
}
Or if not this way, how to load another html in the phonegap webview?

a simple
window.location.href = "file.html";
was the way. :(

Related

file://android_asset/www/index.html was not found

I am new to android programming and I am developing my first apps using eclipse.
I have kept my html and jquery codes inside assets folder.
now this is my code in mainactivity.java
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView webView = (WebView)findViewById(R.id.webview);
webView.getSettings().setJavaScriptEnabled(true);
// webView.setWebChromeClient(new WebChromeClient);
webView.loadUrl("file://android_asset/www/index.html");
}
when i installed app on my device and run it,
it says,
webpage not available,
the file at file://android_asset/www/index.html may have been moved permanently
plz help me to solve this
Try changing
webView.loadUrl("file://android_asset/www/index.html");
by
webView.loadUrl("file:///android_asset/www/index.html"); // please see the extra forward slash, they have to be 3.

How to open PDF file in android pdfviewer not in webview

Plan to develope an android application for open web pdf links in my android application.am opening in webview.But its not good to feel its like a pdf.so thats why plan to open in any adobereader application is installed or any other pdfviewer supported applications already installed in android devise open in thar application or open in webbrowser.
my sample code :1
public class MyPdfViewActivity extends Activity {
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
WebView mWebView=new WebView(MyPdfViewActivity.this);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setPluginsEnabled(true);
mWebView.loadUrl("https://docs.google.com/gview?embedded=true&url="+LinkTo);
setContentView(mWebView);
}
}
sample code 2:
open in webbrowser
How can i open pdf like in ios webview in android with supported guestures and all.
I think, this will help you to some extent: https://github.com/manjusdm/PDFReader

Android Application doesn't read css file completely

hi I have Android App as I embed HTML file , I added my code and when I test the app I noticed that some of css classes doesn't called as #media also the JQuery doesn't called .
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_elaraby_group);
WebView wv=(WebView) findViewById(R.id.web_engine);
wv.loadUrl("file:///android_asset/index.html");
}
Well you have to provide exact same structure you are using in html page in your asses folder.Otherwise it will not get some files referenced in your html file.And hence those CSS and JavaScript code never gets run.So try with providing same structure as your localhost server.

Embed Html Code that contains video streaming in Android

I'm trying to develop an Android application which only shows a video streaming embedded as follows:
<html>
<embed width="650" height="377 "flashvars="backcolor=111111&frontcolor=CCCCCC&lightcolor=66CC00&autostart=true&skin=http://manage.streamcyclone.com/skins/snel.zip&streamer=rtmp://sc-lb1.streamcyclone.com/janakles_live&file=janakles&plugins=http://manage.streamcyclone.com/plugins/qualitymonitor,gapro-1&abouttext=StreamCyclone Player&aboutlink=http://www.streamcyclone.com/&gapro.accountid=UA-679067-4&gapro.trackpercentage=true&gapro.tracktime=true" wmode="opaque" allowscriptaccess="always" allowfullscreen="true" quality="high" name="mpl" id="mpl" style="undefined" src="http://manage.streamcyclone.com/player/player.swf" type="application/x-shockwave-flash"></embed>
</html>
I've put this html file in the assets folder as "broad.html" and here is my code:
public class BroadcastingActivity extends Activity {
WebView engine;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
engine = (WebView) findViewById(R.id.web_engine);
engine.getSettings().setJavaScriptEnabled(true);
engine.getSettings().setAllowFileAccess(true);
engine.getSettings().setPluginsEnabled(true);
engine.getSettings().setSupportZoom(false);
engine.getSettings().setAppCacheEnabled(false);
engine.getSettings().setCacheMode(engine.getSettings().LOAD_NO_CACHE);
engine.loadUrl("file:///android_asset/broad.html");
}
}
I've also set the permission for Internet in the manifest file. But when running. nothing works !!
Any help please ?
You require Flash for this video to work, for more solutions you can read here: using flash with android webview

How can I load a webpage inside the phonegap webview?

I want to be able to link to a webpage inside the phonegap webview that loads an external webpage inside the same phonegap webview. If I do this, it loads inside the webview:
public class App extends DroidGap {
#Override
public void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("http://google.com");
}
}
However, I want to have an internal page launched first, with a link to the external page, so I do this:
public class App extends DroidGap {
#Override
public void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
}
}
and I have a link:
Google
but this link launches google outside the app, in the web browser, instead of in the phonegap webview. What can I do to make sure the link to the external page is launched inside the app's phonegap webview?
Ahhh.. Found the answer on this question.
I had to add
<access origin="www.google.com"/>
to the phonegap.xml file.
This seems to have changed, and access origin seems to have no effect. If you're using the cordova whitelist plugin, as seems to be standard. You need to use allow-navigation in your config.xml file. Without this it will open your web browser.
<plugin name="cordova-plugin-whitelist" version="1"/>
<allow-navigation href="https://google.com/*" />
Then you can use window.location = 'https://google.com' to move to another webpage within your JS.
In the latest phonegab (1.7) in Cordova.plist there is a Key: OpenAllWhitelistURLsInWebView set this to YES.

Categories

Resources