Error in PhoneGap program "Web page not available" - android

package com.phonegap;
import org.apache.cordova.*;
import android.os.Bundle;
public class PhoneGapSampleActivity extends DroidGap {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("assets/www/index.html");
}
}
I use this code for PhoneGap application..
But it shows an error.
I added index.html file in assets/www folder.
But it shows an error ...
Anyone can help me??
Thanks in advance.

You forgot the file:///. Keep in mind it's important to have the three slashes!
Also I think it should be android_asset and not asset.
In my app it is: "file:///android_asset/www/index.html"

Simple Google search came to this :
phonegap doesn't work
The solution was to rename phonegap.0.9.4.js and phonegap.0.9.4.jar to just phonegap.jar and phonegap.js.

Related

Android cordova chromeview : Not implemented reached in virtual quota::SpecialStoragePolicy

I'm working on a phonegap project which contains a canvas overlayed with kinetic.js, which allows a user to pinch zoom and pan around an image, then draw annotations on it. it works spliendidly in a browser and on windows and apple tablets, but of course android is a good bit slower.
as a solution, i've released the app using https://github.com/thedracle/cordova-android-chromeview. after switching my main java class to use ChromeView as the webview, i'm getting this error on startup:
12-03 13:21:09.083: E/chromium(13917): [ERROR:aw_browser_context.cc(191)] Not implemented reached in virtual quota::SpecialStoragePolicy* android_webview::AwBrowserContext::GetSpecialStoragePolicy()
after debugging through the codebase, it looks like the error is triggering here:
private void setNativeContentsClientBridge(int nativeContentsClientBridge) {
mNativeContentsClientBridge = nativeContentsClientBridge;
}
(AwContentsClientBridge.java line 36).
i'm trying to find out what the nativeContentsClientBridge int is. My value is 1611312352 but i haven't a notion of what that represents.
my gut feel is that the chromium browser is missing an implementation for accessing localstorage. i found this bug:
https://github.com/pwnall/chromeview/issues/27
where someone is experiencing the same thing, but there is no solution.
for assistance, this is my main activity class:
package com.companion;
import org.apache.cordova.Config;
import org.apache.cordova.CordovaActivity;
import us.costan.chrome.ChromeSettings;
import us.costan.chrome.ChromeView;
import android.os.Bundle;
public class CompanionApp extends CordovaActivity
{
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState)
{
ChromeView chromeView = new ChromeView(CompanionApp.this);
ChromeSettings settings = chromeView.getSettings();
settings.setJavaScriptEnabled(true);
settings.setDatabaseEnabled(true);
settings.setDomStorageEnabled(true);
setContentView(chromeView);
super.loadUrl(Config.getStartUrl());
}
}
Thanks for your help,
Margaret
Don't know if it's normal, but it seems that a method's not implemented in Chromium base code : https://github.com/01org/pa-chromium/blob/master/android_webview/browser/aw_browser_context.cc
Here's that particular method:
quota::SpecialStoragePolicy* AwBrowserContext::GetSpecialStoragePolicy() {
// TODO(boliu): Implement this so we are not relying on default behavior.
NOTIMPLEMENTED();
return NULL;
}
I hope it helps :)

PhoneGap SplashScreen - splash cannot be resolved or is not a field

i want to make a splash screen on my android application, i use phonegap.
here is my main.java code :
public class App extends DroidGap {
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.setIntegerProperty("splashscreen", R.drawable.splash);
super.loadUrl("file:///android_asset/www/index.html",5000);
}
}
but i got an error : "splash cannot be resolved or is not a field"
i've put the splash.png on every drawable directories, but the error still there..
anybody could help me? thanks in advance..
I think there is an issue about the timeout parameter in your case 5000 and it was fixed in phonegap 1.6.0 release that's why you don't get it work:
these links confirms that
How to use OpenStreetMap/OpenLayers?
phonegap - splash screen for Android app
try to use the last phone gap release (1.8.1) and you will get it work
just change the word splash by screen:
super.setIntegerProperty("splashscreen", R.drawable.screen);
I was having a similar problem. I renamed the package which extended the core DroidGap class. My solution was fixed by this solution: http://www.youtube.com/watch?v=3CHRujojc2o. In short, make sure to update your references in the AndroidManifest.xml file to point to the new package name.

How to enable cookies for Android phonegap 1.8.0 app?

I understood that in order to use cookies inside of phonegap native app there must be piece of code which enables it.
When building phonegap for iOS using xcode 4 there is such piece of code inside of phonegap template.
Could you please advice me which code and where I need to put in order to enable cookies for Android phonegap 1.8.0 app?
Please note that I'm using the eclipse Indigo 3.7.2 for building of the app.
Many thanks.
Cheers,
Sinisa.
If you are trying to use local cookies (file://) you have to make the parent Phonegap project accept local cookies. To do so, You should have a file called youappname.java in your PhoneGap project, probably with this contents or similar:
import android.os.Bundle;
import org.apache.cordova.*;
public class App extends DroidGap {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
}
}
Modify it to look like this example:
import android.os.Bundle;
import android.webkit.CookieManager;
import org.apache.cordova.*;
public class App extends DroidGap {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
CookieManager.setAcceptFileSchemeCookies(true);
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
}
}
you actually wanna do
import android.webkit.CookieManager;
import org.apache.cordova.*;
public class MainActivity extends DroidGap {
#Override
public void onCreate(Bundle savedInstanceState) {
try{
CookieManager.setAcceptFileSchemeCookies(true);
}catch(Throwable e){}
Since the CookieManager does not exist on older Android versions
If my memories are good, the Phonegape's template loads your start-up web page (ex: index.html) by loading it from the webview (something like : super.loadUrl("file:///android_asset/www/index.html");). The latter is declared in the main activity (a ".java" file).
So, first, find the instruction that loads your web application. Then, add the following lines before the webview.loadUrl so that you can obtain something like this :
CookieSyncManager.createInstance(this);
CookieSyncManager.getInstance().startSync();
webView = (WebView) findViewById(R.id.webview);
webview.getSettings().setJavaScriptEnabled(true);
super.loadUrl("file:///android_asset/www/index.html");
Finally, refresh the Android's project and relunch the app.

Adding CookieManager to android Childbrowser

I am trying to get local cookies (file://) to work on android 3.1+
within ChildBrowser. I found a blog response talking about this
specific issue and how to remedy it with Cookie Manager. I can't
figure out where in the plugin to put the code. Has anyone
successfully implemented this?
Comment Below from http://code.google.com/p/android/issues/detail?id=3739
Comment 16 by edtechk...#gmail.com, Feb 1, 2012
I got this thing working, for Android 2.2, javascript's
document.cookie works fine, just make sure that in your
Webview...javascript is enabled like so:
yourWebViewVariable.getSettings().setJavaScriptEnabled(true);
for Android 3.1 just add this to your java file onLoadInit:
CookieManager.setAcceptFileSchemeCookies(true); //This is the line that specifically makes it work so the other lines is optional
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.setAcceptCookie(true);
cookieManager.acceptCookie();
For those interested, I figured it out. It is not a Childbrowser issue at all. You have to make the parent Phonegap project accept local cookies and then Childbrowser will too.
To do so, You should have a file called youappname.java in your PhoneGap project, probably with this contents or similar:
import android.os.Bundle;
import org.apache.cordova.*;
public class App extends DroidGap {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
}
}
Modify it to look like this example:
import android.os.Bundle;
import android.webkit.CookieManager;
import org.apache.cordova.*;
public class App extends DroidGap {
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
CookieManager.setAcceptFileSchemeCookies(true);
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_asset/www/index.html");
}
}

Issue observed with Android app developed using phonegap

I have developed Android applicationusing Phonegap framework with Eclipse pulgin. am not gettting any error in Eclipse but when i'm running the app am able to see the blank app screen.So can someone help me out this issue..
Sample app developed using this link
Please comment asap..
Code:
Java File ----------
package com.phonegap;
import com.phonegap.*;
import android.os.Bundle;
public class HelloworldActivity extends DroidGap
{
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
super.loadUrl("file:///android_assets/www/helloworld.html");
}
}
The problem is in your loadUrl, you should use:
super.loadUrl("file:///android_asset/index.html"); // Singular android_asset, not assets

Categories

Resources