Browse Source

CrashFix

master
Aron Abdulajev 3 years ago
parent
commit
0809d06f3f

+ 10
- 1
app/src/main/java/de/edotzlaff/schockwelle/EarthquakeMapsActivity.java View File

import android.widget.Toast; import android.widget.Toast;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.RequiresApi;
import androidx.core.app.ActivityCompat; import androidx.core.app.ActivityCompat;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentActivity;
import com.google.firebase.database.ValueEventListener; import com.google.firebase.database.ValueEventListener;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneOffset;
import java.util.Calendar; import java.util.Calendar;
import java.util.Date; import java.util.Date;
import java.util.Objects; import java.util.Objects;
} }
} }
@RequiresApi(api = Build.VERSION_CODES.O)
public void onFinish() { public void onFinish() {
if (Math.abs(mAccel) > mUpperThreshold) { if (Math.abs(mAccel) > mUpperThreshold) {
mShakeDetectionIsActive = false; mShakeDetectionIsActive = false;
} }
}; };
@RequiresApi(api = Build.VERSION_CODES.O)
private void writeEarthquakeToDatabase() private void writeEarthquakeToDatabase()
{ {
setDataBaseValues(); setDataBaseValues();
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) { public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults); super.onRequestPermissionsResult(requestCode, permissions, grantResults);
mLocationPermissionsGranted = false; mLocationPermissionsGranted = false;
switch (requestCode) { switch (requestCode) {
case LOCATION_PERMISSION_REQUEST_CODE: { case LOCATION_PERMISSION_REQUEST_CODE: {
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) { if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
return ipAddress; return ipAddress;
} }
@RequiresApi(api = Build.VERSION_CODES.O)
public void setDataBaseValues() public void setDataBaseValues()
{ {
mDatenbank = FirebaseDatabase.getInstance().getReference(); mDatenbank = FirebaseDatabase.getInstance().getReference();
mDatenbank.child("overviewnodes").child("IDG" + indexID).child("a_androidid").setValue(getandroidid()); mDatenbank.child("overviewnodes").child("IDG" + indexID).child("a_androidid").setValue(getandroidid());
/*
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
mDatenbank.child("overviewnodes").child("IDG" + indexID).child("b_localdatetime").setValue(LocalDateTime.now().toString()); mDatenbank.child("overviewnodes").child("IDG" + indexID).child("b_localdatetime").setValue(LocalDateTime.now().toString());
} }
*/
mDatenbank.child("overviewnodes").child("IDG" + indexID).child("b_localdatetime").setValue(LocalDateTime.now(ZoneOffset.UTC).toString());
mDatenbank.child("overviewnodes").child("IDG" + indexID).child("c_ip").setValue(getDeviceIpAdress()); mDatenbank.child("overviewnodes").child("IDG" + indexID).child("c_ip").setValue(getDeviceIpAdress());
mDatenbank.child("overviewnodes").child("IDG" + indexID).child("d_breitengrad").setValue(breitengrad); mDatenbank.child("overviewnodes").child("IDG" + indexID).child("d_breitengrad").setValue(breitengrad);
mDatenbank.child("overviewnodes").child("IDG" + indexID).child("e_laengengrad").setValue(laengengrad); mDatenbank.child("overviewnodes").child("IDG" + indexID).child("e_laengengrad").setValue(laengengrad);

Loading…
Cancel
Save