Last active
August 29, 2015 13:57
-
-
Save suwa-yuki/9801342 to your computer and use it in GitHub Desktop.
AndroidでApplicationContextをどこからでも取得できるようにする
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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