Compare commits
No commits in common. "49aa1ac8a77b3f5b562e793a4c21244ab146f147" and "4c4930ce65823876014674a558b67c669003131b" have entirely different histories.
49aa1ac8a7
...
4c4930ce65
|
@ -35,7 +35,7 @@
|
||||||
<category android:name="android.intent.category.LAUNCHER" />
|
<category android:name="android.intent.category.LAUNCHER" />
|
||||||
</intent-filter>
|
</intent-filter>
|
||||||
</activity>
|
</activity>
|
||||||
<service android:name=".SurveillanceService" />
|
<service android:name=".TestService" />
|
||||||
</application>
|
</application>
|
||||||
|
|
||||||
</manifest>
|
</manifest>
|
|
@ -14,6 +14,7 @@ import android.content.pm.PackageManager;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
import android.os.Vibrator;
|
import android.os.Vibrator;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
@ -133,7 +134,7 @@ public class MainActivity extends AppCompatActivity {
|
||||||
}
|
}
|
||||||
registerReceiver(receiver, intentFilter);
|
registerReceiver(receiver, intentFilter);
|
||||||
|
|
||||||
startForegroundService(new Intent(this, SurveillanceService.class));
|
startForegroundService(new Intent(this, TestService.class));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,8 +3,6 @@ package com.example.childguard;
|
||||||
import static android.content.ContentValues.TAG;
|
import static android.content.ContentValues.TAG;
|
||||||
import static android.content.Context.MODE_PRIVATE;
|
import static android.content.Context.MODE_PRIVATE;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
@ -97,7 +95,6 @@ public class SettingFragment extends Fragment {
|
||||||
SharedPreferences.Editor editor = sharedPreferences1.edit();
|
SharedPreferences.Editor editor = sharedPreferences1.edit();
|
||||||
editor.putString("ID", documentReference.getId());
|
editor.putString("ID", documentReference.getId());
|
||||||
editor.apply();
|
editor.apply();
|
||||||
startTestService();
|
|
||||||
|
|
||||||
Toast.makeText(getActivity(), "初回登録", Toast.LENGTH_SHORT).show();
|
Toast.makeText(getActivity(), "初回登録", Toast.LENGTH_SHORT).show();
|
||||||
getParentFragmentManager().beginTransaction().addToBackStack(null).replace(R.id.fragmentContainerView, GenerateQrFragment.newInstance(documentReference.getId())).commit();
|
getParentFragmentManager().beginTransaction().addToBackStack(null).replace(R.id.fragmentContainerView, GenerateQrFragment.newInstance(documentReference.getId())).commit();
|
||||||
|
@ -109,11 +106,4 @@ public class SettingFragment extends Fragment {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
private void startTestService() {
|
|
||||||
Context context = getContext();
|
|
||||||
if (context != null) {
|
|
||||||
Intent serviceIntent = new Intent(context, SurveillanceService.class);
|
|
||||||
context.startForegroundService(serviceIntent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
|
@ -27,7 +27,9 @@ import androidx.core.app.NotificationManagerCompat;
|
||||||
import com.google.firebase.firestore.DocumentReference;
|
import com.google.firebase.firestore.DocumentReference;
|
||||||
import com.google.firebase.firestore.FirebaseFirestore;
|
import com.google.firebase.firestore.FirebaseFirestore;
|
||||||
|
|
||||||
public class SurveillanceService extends Service {
|
import org.checkerframework.checker.index.qual.LengthOf;
|
||||||
|
|
||||||
|
public class TestService extends Service {
|
||||||
|
|
||||||
private final Handler handler = new Handler();
|
private final Handler handler = new Handler();
|
||||||
private Runnable notificationRunnable;
|
private Runnable notificationRunnable;
|
||||||
|
@ -79,7 +81,6 @@ public class SurveillanceService extends Service {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int onStartCommand(Intent intent, int flags, int startId) {
|
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||||
Log.d(TAG, "onStartCommand: ");
|
|
||||||
this.userId = getSharedPreferences("app_situation", MODE_PRIVATE).getString("ID", null);
|
this.userId = getSharedPreferences("app_situation", MODE_PRIVATE).getString("ID", null);
|
||||||
if (this.userId == null) {
|
if (this.userId == null) {
|
||||||
Log.d("onResume", "ID not initialized.");
|
Log.d("onResume", "ID not initialized.");
|
||||||
|
@ -255,7 +256,7 @@ public class SurveillanceService extends Service {
|
||||||
private PendingIntent getPendingIntent(Context context) {
|
private PendingIntent getPendingIntent(Context context) {
|
||||||
Intent intent = new Intent(context, MainActivity.class);
|
Intent intent = new Intent(context, MainActivity.class);
|
||||||
intent.setAction("OPEN_ACTIVITY");
|
intent.setAction("OPEN_ACTIVITY");
|
||||||
return PendingIntent.getActivity(context, SurveillanceService.REQUEST_CODE, intent, PendingIntent.FLAG_IMMUTABLE);
|
return PendingIntent.getActivity(context, TestService.REQUEST_CODE, intent, PendingIntent.FLAG_IMMUTABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
Loading…
Reference in New Issue
Block a user