Skip to content

Instantly share code, notes, and snippets.

@akexorcist
Last active August 29, 2015 14:26
Show Gist options
  • Save akexorcist/4198ed65a6e452a1d444 to your computer and use it in GitHub Desktop.
Save akexorcist/4198ed65a6e452a1d444 to your computer and use it in GitHub Desktop.
package com.droidsans.photo.droidphoto;
import android.app.Application;
import android.content.Context;
public class BaseApplication extends Application {
private static Context context;
@Override
public void onCreate() {
super.onCreate();
getContext();
}
public static Context getContext() {
if(context == null)
context = getApplicationContext();
return context;
}
}
public static boolean globalEmit(String event, JSONObject obj){
...
Context context = BaseApplication.getContext();
obj.put("_token", context.getSharedPreferences(context.getString(R.string.userdata), Context.MODE_PRIVATE).getString(context.getString(R.string.token), ""));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment