不要なインスタンスを保持しないように

This commit is contained in:
ろむねこ 2024-07-11 15:58:59 +09:00
parent 36cbb5975a
commit a928641410
No known key found for this signature in database
GPG Key ID: FA1F39A1BA37D168

View File

@ -65,18 +65,13 @@ public class TestService extends Service {
@Override @Override
public int onStartCommand(Intent intent, int flags, int startId) { public int onStartCommand(Intent intent, int flags, int startId) {
//共有プリファレンス全体の準備 if (getSharedPreferences("app_situation", MODE_PRIVATE).getString("ID", null) == null) {
SharedPreferences sharedPreferences = getSharedPreferences("app_situation", MODE_PRIVATE);
this.userId = sharedPreferences.getString("ID", null);//アプリに記録されているIDの取得
if (this.userId == null) {
Log.d("onResume", "ID not initialized."); Log.d("onResume", "ID not initialized.");
return flags; // IDが初期化されていない場合は何もしない return flags; // IDが初期化されていない場合は何もしない
} else {
setSnapshotListener(FirebaseFirestore.getInstance().document("status/" + this.userId));
} }
setSnapshotListener(FirebaseFirestore.getInstance().document("status/" + this.userId));
if (isNotBluetoothGranted()) return flags; if (isNotBluetoothGranted()) return flags;
registerReceiver(receiver); registerReceiver(receiver);
return flags; return flags;
} }