我想在我杀死应用程序并且打开应用程序时仍然显示我想要的活动时调用onDestroy方法来制作我的应用程序。但是,当我应用onDestroy时,仍然没有任何反应,也没有显示我想要的活动。我想做的是使应用程序仍然加载数据。告诉我一种执行此方法的方法。我想知道我最终项目的每个细节。
这是我的活动
public class ChooseJob extends AppCompatActivity {
public RecyclerView recyclerView;
public RecyclerView.LayoutManager layoutManager;
FirebaseRecyclerAdapter<BothJobs, OrderViewHolder> adapter;
private FirebaseDatabase database;
private DatabaseReference request;
private DatabaseReference history;
//string Intent
String cName;
String cPhone;
String idJob;
String cImage;
String cAirport;
String cAirlines;
String cLuggage;
String fDetail;
String currentTime;
String cPlace;
TextView orderLayout;
MaterialSpinner spinner;
TextView id;
APIService mService;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_choose_job);
mService = Common.getFCMService();
database = FirebaseDatabase.getInstance();
request = database.getReference("RequestDetail");
history = database.getReference("History");
recyclerView = findViewById(R.id.listOrders);
recyclerView.setHasFixedSize(true);
layoutManager = new LinearLayoutManager(this);
recyclerView.setLayoutManager(layoutManager);
callIntent();
if (getIntent() != null)
loadOrders();
}
@Override
protected void onDestroy() {
super.onDestroy();
callIntent();
if (getIntent() != null)
{
loadOrders();
} else {
Toast.makeText(this, "Nothing HAPPEN!!!", Toast.LENGTH_SHORT).show();
}
}
private void callIntent() {
Intent idJobCarrier = getIntent();
idJob = idJobCarrier.getStringExtra("id");
Intent phoneCarrier = getIntent();
cPhone = phoneCarrier.getStringExtra("carrierPhone");
Intent nameCarrier = getIntent();
cName = nameCarrier.getStringExtra("carrierName");
Intent imageCarrier = getIntent();
cImage = imageCarrier.getStringExtra("carrierImage");
Intent airportCarrier = getIntent();
cAirport = airportCarrier.getStringExtra("carrierAirport");
Intent airlinesCarrier = getIntent();
cAirlines = airlinesCarrier.getStringExtra("carrierAirlines");
Intent locationCarrier = getIntent();
cPlace = locationCarrier.getStringExtra("carrierLocation");
Intent luggageCarrier = getIntent();
cLuggage = luggageCarrier.getStringExtra("carrierLuggage");
Intent flightDetails = getIntent();
fDetail = flightDetails.getStringExtra("flightDetails");
Intent timeStampt = getIntent();
currentTime = timeStampt.getStringExtra("saveCurrentDate");
}
private void loadOrders() {
adapter = new FirebaseRecyclerAdapter<BothJobs, OrderViewHolder>(
BothJobs.class,
R.layout.ob_task,
OrderViewHolder.class,
request.orderByChild("placeSend").equalTo(cPlace)
) {
@Override
protected void populateViewHolder(OrderViewHolder viewHolder, BothJobs model, final int position) {
viewHolder.tvId.setText("ID : " + adapter.getRef(position).getKey());
viewHolder.tvName.setText("Company Name : " + model.getCompanyName());
viewHolder.tvStatus.setText("Status : " + Common.convertCodeToStatus(model.getStatus()));
viewHolder.tvLocation.setText("Location To send : " + model.getPlaceSend());
viewHolder.tvWeight.setText("Weight : " + model.getWeight());
viewHolder.btn_edit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// showUpdateDialog(adapter.getRef(position).getKey(), adapter.getItem(position));
// Toast.makeText(ChooseJob.this, "OK BOS.. aku mau ni job", Toast.LENGTH_SHORT).show();
}
});
}
};
adapter.notifyDataSetChanged();
recyclerView.setAdapter(adapter);
}