In meiner Anwendung, wenn der Benutzer eine Anforderung entsendet er muss auch die Frist setzen. Wenn die Frist fällig ist, möchte ich, dass die App diese Anfrage automatisch löscht. Ich habe noch nichts probiert, weil ich nichts finden kann, was ich brauche.Wie lösche Firebase Kind von Hintergrund-Service, wenn eine Frist fällig ist?
ich zumindest werde den Code anzeigen, wenn der Benutzer sendet eine Anfrage
post = (Button) myView.findViewById(R.id.post);
post.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (ContextCompat.checkSelfPermission(getActivity(), android.Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
if (ActivityCompat.shouldShowRequestPermissionRationale(getActivity(),android.Manifest.permission.ACCESS_COARSE_LOCATION)) {
ActivityCompat.requestPermissions(getActivity(), new String[]{android.Manifest.permission.ACCESS_COARSE_LOCATION}, MY_PERMISSION_REQUEST_LOCATION);
}
else {
ActivityCompat.requestPermissions(getActivity(), new String[]{android.Manifest.permission.ACCESS_COARSE_LOCATION}, MY_PERMISSION_REQUEST_LOCATION);
}
}
else {
LocationManager locationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE);
Location location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
try {
uloc = hereLocation(location.getLatitude(), location.getLongitude());
}
catch (Exception e) {
e.printStackTrace();
//Toast.makeText(getActivity(), "NOT FOUND", Toast.LENGTH_SHORT).show();
}
}
dead = deadline.getText().toString();
r = reqdesc.getText().toString();
if(reqdesc.getText().toString().trim().length()==0){
Toast.makeText(getActivity(), "PLEASE ENTER YOUR REQUEST", Toast.LENGTH_LONG).show();
}
else if(click==0 || dl==null){
Toast.makeText(getActivity(), "PLEASE SET THE DEADLINE FOR YOUR REQUEST", Toast.LENGTH_LONG).show();
}
else {
String date = java.text.DateFormat.getDateTimeInstance().format(Calendar.getInstance().getTime());
writeNewRequest(r, dead, uemail, uid, uname, uprofile, uloc, date);
String reqKey = p.getKey().toString();
writeDuplicate(reqKey, r, dead, uemail, uid, uname, uprofile, uloc, date);
Intent i = new Intent(getActivity(), RequestConfirm.class);
i.putExtra("key", reqKey);
startActivity(i);
//showNotification();
}
}
});
# 1 klingt einfacher als diese. Aber ich habe keine Ahnung, wie ich das programmieren soll – exc3m