Skip to content

Instantly share code, notes, and snippets.

@suwa-yuki
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save suwa-yuki/9801342 to your computer and use it in GitHub Desktop.
Save suwa-yuki/9801342 to your computer and use it in GitHub Desktop.
AndroidでApplicationContextをどこからでも取得できるようにする
package jp.sample.core;
import android.app.Application;
import android.content.Context;
/**
* .
*/
public class App extends Application {
/** Logcat出力用タグ. */
private static final String TAG = App.class.getSimpleName();
/** 自身のインスタンス. */
private final App self = this;
private static Context sContext;
@Override
public void onCreate() {
super.onCreate();
sContext = this;
}
public static Context getContext() {
return sContext;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment