Skip to content

Instantly share code, notes, and snippets.

@shikto1
Last active January 11, 2020 13:22
Show Gist options
  • Select an option

  • Save shikto1/c549869a6c8bc7689be55591158f5541 to your computer and use it in GitHub Desktop.

Select an option

Save shikto1/c549869a6c8bc7689be55591158f5541 to your computer and use it in GitHub Desktop.
public class SingletonSampleClass {
private Context mContext;
private static SingletonSampleClass instance = null;
private SingletonSampleClass(Context context) {
this.mContext = mContext;
}
public synchronized static SingletonSampleClass getInstance(Context mContext) {
if (instance == null) instance = new SingletonSampleClass(mContext);
return instance;
}
public void onDestroy() {
if(mContext != null) {
mContext = null;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment