我有一個名爲ForegroundService服務類onstartCommand,我需要設置一個變量:Android的 - 不能設置在服務類中的變量
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
VariableManaging.isStop=false; //<==variable i need to set. Here i got an exceptioninInitializer error when my bootReceiver start service on startup. If service is start by button on activity got no error.
}
VariableManaging類開始:
static boolean isStop=true;
static ProgressDialog progressDialog=new ProgressDialog(Main.activity); //<== I noted that if i remove this all working well
有一種方法來設置該變量?
是什麼?Main.activity它是一個靜態變量嗎? – KhalidTaha