모바일 프로그래밍/안드로이드 프로그래밍

Application으로 싱글톤 만들기

zelkova 2020. 6. 8. 11:35


<목차로 돌아가기>


application name지정 안하면 에러뜬다 주의하자.


<application

android:name=".뿅뿅뿅♡Application"
android:allowBackup="true"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">


public class 뿅뿅뿅♡Application extends Application {

private static 뿅뿅뿅♡Application _instance;

private ViewPageContoller curActivity;

@Override
public void onCreate() {
super.onCreate();
_instance = this;
NotificationHelper.createNotificationChannel(this);
}
public static 뿅뿅뿅♡Application getInstance() {
return _instance;
}

public void setCurActivity(ViewPageContoller activity) {
this.curActivity = activity;
}
public ViewPageContoller getCurActivity() {
return curActivity;
}
}



반응형