Pascal Adam
Pascal Adam

Reputation: 23

LoadUrl in PhoneGap and Android

I am working on an app for android using phonegap and unity. I wrote a plugin for phonegap that starts a new activity from phonegap that loads the unity player. When i hit the back button in the unity activity i want to go back to the phonegap activity and load my webcontainer again, but with a different url. Whatever i try, it still loads the URL i loaded the first time. Is there any way to fix that? Here is the Activity:

public class PhonegapCallsActivity extends DroidGap {

private static Boolean backButton;

    private static String url;
    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        Bundle extras = getIntent().getExtras();
        if (extras == null) {
            Log.d("false","ERROR");
                //load index.html when i enter first time
            super.loadUrl("file:///android_asset/www/index.html");  
            return;
                }

        else{
        backButton = extras.getBoolean("backButton");
            //load #two when i come back
                Log.d("true","ERROR");
            super.loadUrl("file:///android_asset/www/index.html#two");

        } 
}

Note that logcat is tracing true and false correctly, so my variables are set properly. I always get the index.html loaded, never index.html#two. Is it stored somewhere?

Upvotes: 2

Views: 4818

Answers (1)

Simon MacDonald
Simon MacDonald

Reputation: 23273

You are doing it right but you are running into an Android bug. Go star:

In the mean time the best way to work around this issue is to store a flag in localStorage to check if you should be loading page one or page two in the JavaScript.

Upvotes: 1

Related Questions