IDが生成されたときに、サービスの起動を行うようにした
ついでに、サービスの名前も変えた
This commit is contained in:
1 parent
4c4930ce65
commit
16265d5d31
4 files changed
+15
-7
No files matched your search
@@ -3,6 +3,8 @@ package com.example.childguard;
|
||||
import static android.content.ContentValues.TAG;
|
||||
import static android.content.Context.MODE_PRIVATE;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
@@ -95,6 +97,7 @@ public class SettingFragment extends Fragment {
|
||||
SharedPreferences.Editor editor = sharedPreferences1.edit();
|
||||
editor.putString("ID", documentReference.getId());
|
||||
editor.apply();
|
||||
startTestService();
|
||||
|
||||
Toast.makeText(getActivity(), "初回登録", Toast.LENGTH_SHORT).show();
|
||||
getParentFragmentManager().beginTransaction().addToBackStack(null).replace(R.id.fragmentContainerView, GenerateQrFragment.newInstance(documentReference.getId())).commit();
|
||||
@@ -106,4 +109,11 @@ public class SettingFragment extends Fragment {
|
||||
}
|
||||
});
|
||||
}
|
||||
private void startTestService() {
|
||||
Context context = getContext();
|
||||
if (context != null) {
|
||||
Intent serviceIntent = new Intent(context, SurveillanceService.class);
|
||||
context.startForegroundService(serviceIntent);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user