Projektteil 2
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MainActivity.java 26KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577
  1. package de.edotzlaff.detection;
  2. import androidx.annotation.NonNull;
  3. import androidx.annotation.RequiresApi;
  4. import androidx.appcompat.app.AppCompatActivity;
  5. import androidx.core.app.ActivityCompat;
  6. import androidx.core.content.ContextCompat;
  7. import android.Manifest;
  8. import android.app.Dialog;
  9. import android.content.Context;
  10. import android.content.Intent;
  11. import android.content.pm.PackageManager;
  12. import android.hardware.Sensor;
  13. import android.hardware.SensorEvent;
  14. import android.hardware.SensorEventListener;
  15. import android.hardware.SensorManager;
  16. import android.location.Location;
  17. import android.os.Build;
  18. import android.os.Bundle;
  19. import android.os.CountDownTimer;
  20. import android.provider.Settings;
  21. import android.util.Log;
  22. import android.view.View;
  23. import android.widget.Button;
  24. import android.widget.TextView;
  25. import android.widget.Toast;
  26. import com.google.android.gms.common.ConnectionResult;
  27. import com.google.android.gms.common.GoogleApiAvailability;
  28. import com.google.android.gms.location.FusedLocationProviderClient;
  29. import com.google.android.gms.location.LocationServices;
  30. import com.google.android.gms.maps.GoogleMap;
  31. import com.google.android.gms.tasks.OnCompleteListener;
  32. import com.google.android.gms.tasks.Task;
  33. import com.google.firebase.database.DataSnapshot;
  34. import com.google.firebase.database.DatabaseError;
  35. import com.google.firebase.database.DatabaseReference;
  36. import com.google.firebase.database.FirebaseDatabase;
  37. import com.google.firebase.database.ValueEventListener;
  38. import java.time.LocalDateTime;
  39. import java.time.ZoneOffset;
  40. import java.util.Calendar;
  41. import java.util.Objects;
  42. public class MainActivity extends AppCompatActivity {
  43. private static final String TAG = "MainActivity";
  44. private static final int ERROR_DIALOG_REQUEST = 9001;
  45. private static final String FINE_LOCATION = Manifest.permission.ACCESS_FINE_LOCATION;
  46. private static final int LOCATION_PERMISSION_REQUEST_CODE = 1234;
  47. private Boolean mLocationPermissionsGranted = false;
  48. private GoogleMap mMap;
  49. private FusedLocationProviderClient mFusedLocationProviderClient;
  50. Long currentTime;
  51. Location currentLocation;
  52. private DatabaseReference mDatenbank;
  53. private double breitengrad;
  54. private double laengengrad;
  55. private boolean useOwnGPS = true;
  56. private int indexID = 1;
  57. private int writtenDevices = 1;
  58. private boolean allowCalculation = true;
  59. private boolean enableDisplayReset = true;
  60. //##########################################################################################################################################################################
  61. //################################################################## vvv SensorParameter vvv ##############################################################################
  62. private SensorManager mSensorManager;
  63. private static final float mUpperThreshold = 0.075f; // für Emulator auf 1.5 setzen
  64. private static final float mLowerThreshold = 0.5f; // für Emulator auf 0.5 setzen
  65. private static final long mShakeDetectionLockTimeMicroSeconds = 3500;
  66. private float mAccel;
  67. private float mAccelCurrent;
  68. private float mAccelLast;
  69. private boolean mShakeDetectionIsActive = false;
  70. private boolean mShakeDetected = false;
  71. private boolean allowShakeEvent = true;
  72. //################################################################## ^^^^ SensorParameter ^^^^ ############################################################################
  73. //##########################################################################################################################################################################
  74. @Override
  75. protected void onCreate(Bundle savedInstanceState) {
  76. super.onCreate(savedInstanceState);
  77. setContentView(R.layout.activity_main);
  78. if (isServiceOK()){
  79. init();
  80. }
  81. sensorManagementInit();
  82. initDataBase();
  83. getLocationPermission();
  84. getDataBaseValuesWithListener();
  85. }
  86. //################################################################## vvv Detection Code vvv ###################################################################################
  87. //##########################################################################################################################################################################
  88. private void sensorManagementInit()
  89. {
  90. //TextView txtEarthquake = (TextView) findViewById(R.id.txtEarthquake);
  91. mSensorManager = (SensorManager) getSystemService(Context.SENSOR_SERVICE);
  92. Objects.requireNonNull(mSensorManager).registerListener(mSensorListener, mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER), SensorManager.SENSOR_DELAY_FASTEST);
  93. mAccel = 0.05f;
  94. mAccelCurrent = SensorManager.GRAVITY_EARTH;
  95. mAccelLast = SensorManager.GRAVITY_EARTH;
  96. mShakeDetectionIsActive = false;
  97. mShakeDetected = false;
  98. }
  99. private final SensorEventListener mSensorListener = new SensorEventListener() {
  100. @Override
  101. public void onSensorChanged(SensorEvent event) {
  102. float x = event.values[0];
  103. float y = event.values[1];
  104. float z = event.values[2];
  105. mAccelLast = mAccelCurrent;
  106. mAccelCurrent = (float) Math.sqrt((double) (x * x + y * y + z * z));
  107. float delta = mAccelCurrent - mAccelLast;
  108. mAccel = mAccel * 0.9f + delta;
  109. Log.d(TAG,"mAccel: "+ mAccel);
  110. if (mShakeDetectionIsActive && !mShakeDetected) {
  111. if(Math.abs(mAccel) > mUpperThreshold) {
  112. new CountDownTimer(500, 10) {
  113. public void onTick(long millisUntilFinished) {
  114. mShakeDetectionIsActive = false;
  115. /* if (Math.abs(mAccel) > mUpperThreshold) {
  116. mShakeDetectionIsActive = false;
  117. } else if (Math.abs(mAccel) < mLowerThreshold) {
  118. mShakeDetectionIsActive = true;
  119. this.cancel();
  120. }
  121. */
  122. }
  123. public void onFinish() {
  124. if (Math.abs(mAccel) > mUpperThreshold) {
  125. mShakeDetectionIsActive = false;
  126. mShakeDetected = true;
  127. earthquakeDetected();
  128. } else {
  129. mShakeDetectionIsActive = true;
  130. mShakeDetected = false;
  131. }
  132. }
  133. }.start();
  134. }
  135. }
  136. }
  137. @Override
  138. public void onAccuracyChanged(Sensor sensor, int accuracy) {
  139. }
  140. };
  141. private void earthquakeDetected()
  142. {
  143. Toast.makeText(getApplicationContext(), "Earthquake detected", Toast.LENGTH_SHORT).show();
  144. Log.d(TAG,"!Earthquake detected!");
  145. //Hier wird bei Vibration in DB geschrieben
  146. getDataBaseValuesNoListenerForVibration();
  147. Button buttonReadyToDetect = (Button) findViewById(R.id.buttonReadyToDetect);
  148. buttonReadyToDetect.setEnabled(true);
  149. }
  150. //################################################################## ^^^^ Detection Code ^^^^ ###################################################################################
  151. //##########################################################################################################################################################################
  152. //##########################################################################################################################################################################
  153. //################################################################## vvv Get Location from Device vvv ####################################################################
  154. private void getLocationPermission() {
  155. String[] permissions = {Manifest.permission.ACCESS_FINE_LOCATION};
  156. if (ContextCompat.checkSelfPermission(this.getApplicationContext(), FINE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
  157. mLocationPermissionsGranted = true;
  158. getDeviceLocation();
  159. } else {
  160. ActivityCompat.requestPermissions(this, permissions, LOCATION_PERMISSION_REQUEST_CODE);
  161. }
  162. }
  163. private void getDeviceLocation(){
  164. mFusedLocationProviderClient = LocationServices.getFusedLocationProviderClient(this);
  165. try {
  166. if (mLocationPermissionsGranted){
  167. final Task location = mFusedLocationProviderClient.getLastLocation();
  168. location.addOnCompleteListener(new OnCompleteListener() {
  169. @Override
  170. public void onComplete(@NonNull Task task) {
  171. if (task.isSuccessful()){
  172. currentLocation = (Location) task.getResult();
  173. if(useOwnGPS)
  174. {
  175. breitengrad = currentLocation.getLatitude();
  176. laengengrad = currentLocation.getLongitude();
  177. }
  178. currentLocation.setLatitude(breitengrad);
  179. currentLocation.setLongitude(laengengrad);
  180. //setText();
  181. }
  182. else{
  183. Toast.makeText(MainActivity.this, "Current Location unavailable", Toast.LENGTH_SHORT).show();
  184. }
  185. }
  186. });
  187. }
  188. }catch (SecurityException e){
  189. Log.e(TAG,"Device Location not found" + e.getMessage());
  190. }
  191. }
  192. //################################################################## ^^^^ Get Location from Device ^^^^ ##################################################################
  193. //##########################################################################################################################################################################
  194. //##########################################################################################################################################################################
  195. //################################################################## vvv DB Code vvv #####################################################################################
  196. //###### Für Start der APP ####
  197. public void initDataBase()
  198. {
  199. getDataBaseValuesNoListener();
  200. }
  201. public void getDataBaseValuesNoListener()
  202. {
  203. mDatenbank = FirebaseDatabase.getInstance().getReference().child("overviewdetection");
  204. mDatenbank.get().addOnCompleteListener(new OnCompleteListener<DataSnapshot>() {
  205. @Override
  206. public void onComplete(@NonNull Task<DataSnapshot> task) {
  207. if (!task.isSuccessful()) {
  208. System.out.println("Datenbank Fehler in getDataBaseValuesNoListener");
  209. }
  210. else {
  211. analyzeForEmptyDB(task.getResult());
  212. }
  213. }
  214. });
  215. }
  216. //Methode bestimmt, ob DB mit leer IDGn Felder überhaupt vorhanden ist
  217. public void analyzeForEmptyDB(DataSnapshot data)
  218. {
  219. String androidid;
  220. String localedatetime;
  221. String breitengrad;
  222. String laengengrad;
  223. String timestamp;
  224. String ampltiude;
  225. String welle;
  226. int emptyIDG =0;
  227. for (int i=1; i<=data.getChildrenCount(); i++)
  228. {
  229. androidid = data.child("IDG" + i).child("a_androidid").getValue().toString();
  230. localedatetime = data.child("IDG" + i).child("b_localdatetime").getValue().toString();
  231. breitengrad = data.child("IDG" + i).child("d_breitengrad").getValue().toString();
  232. laengengrad = data.child("IDG" + i).child("e_laengengrad").getValue().toString();
  233. timestamp = data.child("IDG" + i).child("h_timestamp").getValue().toString();
  234. ampltiude = data.child("IDG" + i).child("i_amplitude").getValue().toString();
  235. welle = data.child("IDG" + i).child("w_wellengeschwindigkeit").getValue().toString();
  236. if(androidid.isEmpty() && localedatetime.isEmpty() && breitengrad.isEmpty() && laengengrad.isEmpty() && timestamp.isEmpty() && ampltiude.isEmpty() && welle.isEmpty())
  237. {
  238. emptyIDG++;
  239. }else{
  240. emptyIDG--;
  241. }
  242. }
  243. //Wenn DB nicht vorhanden ODER leer ist, erstelle diese DB mit IDG 1-5
  244. if(emptyIDG == data.getChildrenCount())
  245. {
  246. for (int i=1; i<=5; i++)
  247. {
  248. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
  249. writeEmptyToSecondDataBase(i);
  250. }
  251. }
  252. }
  253. }
  254. @RequiresApi(api = Build.VERSION_CODES.O)
  255. public void writeEmptyToSecondDataBase(int k)
  256. {
  257. mDatenbank = FirebaseDatabase.getInstance().getReference().child("overviewdetection");
  258. mDatenbank.child("IDG" + k).child("a_androidid").setValue("");
  259. mDatenbank.child("IDG" + k).child("b_localdatetime").setValue("");
  260. mDatenbank.child("IDG" + k).child("d_breitengrad").setValue("");
  261. mDatenbank.child("IDG" + k).child("e_laengengrad").setValue("");
  262. mDatenbank.child("IDG" + k).child("h_timestamp").setValue("");
  263. mDatenbank.child("IDG" + k).child("i_amplitude").setValue("");
  264. mDatenbank.child("IDG" + k).child("w_wellengeschwindigkeit").setValue("");
  265. }
  266. //###### Bei Vibration der APP ####
  267. public void getDataBaseValuesNoListenerForVibration()
  268. {
  269. mDatenbank = FirebaseDatabase.getInstance().getReference().child("overviewdetection");
  270. mDatenbank.get().addOnCompleteListener(new OnCompleteListener<DataSnapshot>() {
  271. @Override
  272. public void onComplete(@NonNull Task<DataSnapshot> task) {
  273. if (!task.isSuccessful()) {
  274. System.out.println("Datenbank Fehler in getDataBaseValuesNoListener");
  275. }
  276. else {
  277. checkForEmptyIDG(task.getResult());
  278. }
  279. }
  280. });
  281. }
  282. public void checkForEmptyIDG(DataSnapshot data)
  283. {
  284. for (int i=1; i<=data.getChildrenCount(); i++)
  285. {
  286. if(analyzeForEmptyIDG(data,i))
  287. {
  288. writeDeviceToDB(i);
  289. break;
  290. }
  291. }
  292. }
  293. public boolean analyzeForEmptyIDG(DataSnapshot data, int i)
  294. {
  295. String androidid;
  296. String localedatetime;
  297. String breitengrad;
  298. String laengengrad;
  299. String timestamp;
  300. String ampltiude;
  301. String welle;
  302. androidid = data.child("IDG" + i).child("a_androidid").getValue().toString();
  303. localedatetime = data.child("IDG" + i).child("b_localdatetime").getValue().toString();
  304. breitengrad = data.child("IDG" + i).child("d_breitengrad").getValue().toString();
  305. laengengrad = data.child("IDG" + i).child("e_laengengrad").getValue().toString();
  306. timestamp = data.child("IDG" + i).child("h_timestamp").getValue().toString();
  307. ampltiude = data.child("IDG" + i).child("i_amplitude").getValue().toString();
  308. welle = data.child("IDG" + i).child("w_wellengeschwindigkeit").getValue().toString();
  309. if(androidid.isEmpty() && localedatetime.isEmpty() && breitengrad.isEmpty() && laengengrad.isEmpty() && timestamp.isEmpty() && ampltiude.isEmpty() && welle.isEmpty())
  310. {
  311. return true;
  312. }else
  313. {
  314. return false;
  315. }
  316. }
  317. public void writeDeviceToDB (int k)
  318. {
  319. mDatenbank = FirebaseDatabase.getInstance().getReference().child("overviewdetection");
  320. mDatenbank.child("IDG" + k).child("a_androidid").setValue(getandroidid());
  321. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
  322. mDatenbank.child("IDG" + k).child("b_localdatetime").setValue(LocalDateTime.now(ZoneOffset.UTC).toString());
  323. }
  324. mDatenbank.child("IDG" + k).child("d_breitengrad").setValue(currentLocation.getLatitude());
  325. mDatenbank.child("IDG" + k).child("e_laengengrad").setValue(currentLocation.getLongitude());
  326. mDatenbank.child("IDG" + k).child("h_timestamp").setValue(Calendar.getInstance().getTimeInMillis());
  327. mDatenbank.child("IDG" + k).child("i_amplitude").setValue(1000);
  328. mDatenbank.child("IDG" + k).child("w_wellengeschwindigkeit").setValue(10);
  329. }
  330. //###### Bei Eintragungen in der DB ####
  331. public void getDataBaseValuesWithListener()
  332. {
  333. mDatenbank = FirebaseDatabase.getInstance().getReference().child("overviewdetection");
  334. mDatenbank.addValueEventListener(new ValueEventListener() {
  335. @Override
  336. public void onDataChange(@NonNull DataSnapshot snapshot) {
  337. analyzeDBchanges(snapshot);
  338. }
  339. @Override
  340. public void onCancelled(@NonNull DatabaseError error) {
  341. getDataBaseFailure(error);
  342. }
  343. });
  344. }
  345. public void analyzeDBchanges(DataSnapshot data)
  346. {
  347. for (int i=1; i<=data.getChildrenCount(); i++)
  348. {
  349. if(analyzeForFullIDG(data,i) || analyzeForEmptyIDG(data,i))
  350. {
  351. TextView txtDevice1 = (TextView) findViewById(R.id.txtdevice1);
  352. TextView txtDevice2 = (TextView) findViewById(R.id.txtdevice2);
  353. TextView txtDevice3 = (TextView) findViewById(R.id.txtdevice3);
  354. TextView txtDevice4 = (TextView) findViewById(R.id.txtdevice4);
  355. String dbSlotStringContent = getSlotString(data,i);
  356. String displayContent;
  357. switch (i){
  358. case 1:
  359. displayContent = txtDevice1.getText().toString();
  360. if(!displayContent.equals(dbSlotStringContent))
  361. {
  362. if(analyzeForEmptyIDG(data,i))
  363. {
  364. txtDevice1.setText("");
  365. }else
  366. {
  367. txtDevice1.setText(dbSlotStringContent);
  368. }
  369. }
  370. break;
  371. case 2:
  372. displayContent = txtDevice2.getText().toString();
  373. if(!displayContent.equals(dbSlotStringContent))
  374. {
  375. if(analyzeForEmptyIDG(data,i))
  376. {
  377. txtDevice2.setText("");
  378. }else
  379. {
  380. txtDevice2.setText(dbSlotStringContent);
  381. }
  382. }
  383. break;
  384. case 3:
  385. displayContent = txtDevice3.getText().toString();
  386. if(!displayContent.equals(dbSlotStringContent))
  387. {
  388. if(analyzeForEmptyIDG(data,i))
  389. {
  390. txtDevice3.setText("");
  391. }else
  392. {
  393. txtDevice3.setText(dbSlotStringContent);
  394. }
  395. }
  396. break;
  397. case 4:
  398. displayContent = txtDevice4.getText().toString();
  399. if(!displayContent.equals(dbSlotStringContent))
  400. {
  401. if(analyzeForEmptyIDG(data,i))
  402. {
  403. txtDevice4.setText("");
  404. }else
  405. {
  406. txtDevice4.setText(dbSlotStringContent);
  407. }
  408. }
  409. break;
  410. default:
  411. break;
  412. }
  413. }
  414. }
  415. int takenIDG = 0;
  416. for (int i=1; i<=data.getChildrenCount(); i++)
  417. {
  418. if(analyzeForFullIDG(data,i))
  419. {
  420. takenIDG++;
  421. }
  422. }
  423. if(takenIDG >= 3 && allowCalculation)
  424. {
  425. Toast.makeText(MainActivity.this, "3 Geräte regisrtiert - Berechnung möglich!", Toast.LENGTH_SHORT).show();
  426. allowCalculation = false;
  427. Button btnEarthquake = (Button) findViewById(R.id.btnEarthquakeLocation);
  428. btnEarthquake.setEnabled(true);
  429. }
  430. }
  431. public String getSlotString(DataSnapshot data,int i)
  432. {
  433. String androidid = data.child("IDG" + i).child("a_androidid").getValue().toString();
  434. String localedatetime = data.child("IDG" + i).child("b_localdatetime").getValue().toString();
  435. String breitengrad = data.child("IDG" + i).child("d_breitengrad").getValue().toString();
  436. String laengengrad = data.child("IDG" + i).child("e_laengengrad").getValue().toString();
  437. String timestamp = data.child("IDG" + i).child("h_timestamp").getValue().toString();
  438. String ampltiude = data.child("IDG" + i).child("i_amplitude").getValue().toString();
  439. String databaseSlotString = "Device ID " + i + ": "+ androidid + "\n" + "Latitude: "+breitengrad+"\n"+ "Longitude: "+ laengengrad +"\n" + "Time Stamp: "+ timestamp + "\n" + "LocalDateTime: " + localedatetime +"\n"+ "Amplitude: "+ ampltiude+"\n";
  440. return databaseSlotString;
  441. }
  442. public boolean analyzeForFullIDG(DataSnapshot data, int i)
  443. {
  444. String androidid = data.child("IDG" + i).child("a_androidid").getValue().toString();
  445. String localedatetime = data.child("IDG" + i).child("b_localdatetime").getValue().toString();
  446. String breitengrad = data.child("IDG" + i).child("d_breitengrad").getValue().toString();
  447. String laengengrad = data.child("IDG" + i).child("e_laengengrad").getValue().toString();
  448. String timestamp = data.child("IDG" + i).child("h_timestamp").getValue().toString();
  449. String ampltiude = data.child("IDG" + i).child("i_amplitude").getValue().toString();
  450. String welle = data.child("IDG" + i).child("w_wellengeschwindigkeit").getValue().toString();
  451. if(!androidid.isEmpty() && !localedatetime.isEmpty() && !breitengrad.isEmpty() && !laengengrad.isEmpty() && !timestamp.isEmpty() && !ampltiude.isEmpty() && !welle.isEmpty())
  452. {
  453. return true;
  454. }else
  455. {
  456. return false;
  457. }
  458. }
  459. public String getandroidid ()
  460. {
  461. return Settings.Secure.getString(this.getContentResolver(), Settings.Secure.ANDROID_ID);
  462. }
  463. public void getDataBaseFailure (DatabaseError error)
  464. {
  465. System.out.println("Fehler");
  466. Log.w("Datenbankfehler", error.toException());
  467. }
  468. //################################################################## ^^^^ DB Code ^^^^ ###################################################################################
  469. //##########################################################################################################################################################################
  470. //##########################################################################################################################################################################
  471. //################################################################## vvv Maps Code vvv ###################################################################################
  472. public boolean isServiceOK(){
  473. Log.d(TAG, "isServicesOK(): checking google services version");
  474. int available = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(MainActivity.this);
  475. if (available== ConnectionResult.SUCCESS){
  476. Log.d(TAG,"isServicesOK: Google Play Services is working");
  477. return true;
  478. }
  479. else if (GoogleApiAvailability.getInstance().isUserResolvableError(available)){
  480. Log.d(TAG, "isServicesOK(): an error occured but we can fix it");
  481. Dialog dialog = GoogleApiAvailability.getInstance().getErrorDialog(MainActivity.this, available, ERROR_DIALOG_REQUEST);
  482. dialog.show();
  483. }
  484. else {
  485. Toast.makeText(this, "You can`t make map request", Toast.LENGTH_SHORT).show();
  486. }
  487. return false;
  488. }
  489. private void init() {
  490. Button btnEarthquake = (Button) findViewById(R.id.btnEarthquakeLocation);
  491. btnEarthquake.setEnabled(false);
  492. btnEarthquake.setOnClickListener(new View.OnClickListener() {
  493. @Override
  494. public void onClick(View v) {
  495. Intent intent = new Intent(MainActivity.this, EarthquakeLocation.class);
  496. startActivity(intent);
  497. }
  498. });
  499. Button btnResetDB = (Button) findViewById(R.id.btnResetDB);
  500. btnResetDB.setOnClickListener(new View.OnClickListener() {
  501. @RequiresApi(api = Build.VERSION_CODES.O)
  502. @Override
  503. public void onClick(View v) {
  504. for (int i=1; i<=5; i++)
  505. {
  506. writeEmptyToSecondDataBase(i);
  507. }
  508. }
  509. });
  510. Button btnReadyToDetect = (Button) findViewById(R.id.buttonReadyToDetect);
  511. btnReadyToDetect.setOnClickListener(new View.OnClickListener() {
  512. @RequiresApi(api = Build.VERSION_CODES.O)
  513. @Override
  514. public void onClick(View v) {
  515. mShakeDetectionIsActive = true;
  516. mShakeDetected = false;
  517. btnReadyToDetect.setEnabled(false);
  518. }
  519. });
  520. }
  521. //################################################################## ^^^^ Maps Code ^^^^ ##################################################################
  522. //###########################################################################################################################################################
  523. }