4

I have an app built for Android (and hopefully soon iPhone) using Phonegap's web interface AppLaud.

It's working almost perfectly, except that it does not seem to be acknowledging cookie data.

I saw this question, which addresses pretty much the same issue, except the answer is targeted for the Phonegap Eclipse plugin. Even if I understood the answer (which I don't fully), I don't see how I would apply it in the AppLaud interface.

How do I get an AppLaud built app to store and receive cookies?

Community
  • 1
  • 1
Questioner
  • 7,133
  • 16
  • 61
  • 94

1 Answers1

2

I would try the methods exposed here: Android: How to store cookies? by adding them to the onCreate or init methods of the App.java class of the PhoneGap project.

You should have a file called app.java in your PhoneGap project, probably with this contents or similar:

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 to test the CodeSyncManager example:

public class App extends DroidGap {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        CookieSyncManager.getInstance().sync();
        super.onCreate(savedInstanceState);
        super.loadUrl("file:///android_asset/www/index.html");
    }
}
Community
  • 1
  • 1
adosaiguas
  • 1,331
  • 9
  • 13
  • Sorry, but I don't do any Java programming at all (otherwise I'd skip Phonegap and just develop a native Android app), and so this is a little beyond me. If there are instructions that can be utilized by a non-Java-programmer, then that would be fantastic. – Questioner May 24 '12 at 08:21
  • Well, to make this work it seems that you need to add native code both for Android and iOS. I will try to comeup with and example so you can easily test. – adosaiguas May 24 '12 at 21:04
  • Thank you for providing code and clear instructions. Unfortunately, there doesn't seem to be any App.java class anywere in the files I have access to within the AppLaud interface. – Questioner May 25 '12 at 00:37
  • The App.java file is at the lowest layer of the src directory in an AppLaud project – Paul Beusterien May 25 '12 at 01:46
  • Thanks for this helpful answer. I awarded you the bounty, as you were providing concrete help. However, in the end the issue was mooted by using local storage, a solution I got to by asking in [this question](http://stackoverflow.com/q/10747280/184108). – Questioner May 25 '12 at 01:54
  • @PaulBeusterien: Oh, I get it now. I thought there was literally a file called "app.java", but you guys mean a file called "(name of my app).java". Now I see it. – Questioner May 25 '12 at 01:59