-1

I'm currently developing an app for android in eclipse And for this app, im going to connect it to the web services to an existing database I'm currently building the login page and i managed to connect it to the database and got a session id, however, im wondering how im going to connect the rest of the app to that session ID and save all the things that the user will do in the actual app to the same user who logged in, so basically, how to connect the app all together to the same person who logged in?

Its my first app so I'm not really experienced

Mash
  • 174
  • 1
  • 1
  • 12
  • Effectively, this is session management. This is definitely a very broad subject which covers a lot of ground. It really depends on what you're using as your session manager, and how you were planning on managing that (logout state, "remember-me" state, etc). Unfortunately, it feels very broad. If you're having confusions on what session management actually is, there are other tutorials out there on the 'Net that can help you clearly define it. – Makoto Jul 01 '14 at 06:49

1 Answers1

0

i had exactly the same problem for my first app.

I did the following :

Create a class which extends application.

public class App_Web extends Application{

    public static AsyncHttpClient client = new AsyncHttpClient();

    @Override
    public void onCreate() {
        super.onCreate();
        //initialize myObject here, if needed
    }

    public static void deconnexion() {
        client = new AsyncHttpClient();
    }

The public static AsyncHttpClient allows me to use it from every class or activity. For example :

App_Web.client.post("your_url", null, new JsonHttpResponseHandler() {
    @Override
    public void onSuccess(JSONObject data) {
       // success code here
    }

So basically, it has the same session.

(I really recommend you to use this library but if you don't want to, the idea should be the same for an other !)

Good luck ;)

maxime1992
  • 22,502
  • 10
  • 80
  • 121