okay here is my problem
- I have a Fragment that contains RecyclerView, and of course an adapter (called
ApprovalCutiCardAdapter) that hold the content. Inside that
ApprovalCutiCardAdapterI set OnClickListener on the card, when Card is clicked it will launch an Activity calledDetailApprovalCuti. Here is my code to launch the activity((Activity) MyApplication.getmContext()).startActivityForResult(detailApprovalCutiIntent, 1);In
DetailApprovalCutiI'm executingfinishActivity(1)to get an event ofonActivityResult. But that event is not being called everywhere (in Activity that host the fragment, and in the fragment)@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { Log.e("result", "ApprovalIzinCutiFragment"); super.onActivityResult(requestCode, resultCode, data); }Here's my code to start the Acvitity
@Override public void onBindViewHolder(final CutiViewHolder holder, final int position) { .... holder.cv.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent detailApprovalCutiIntent = new Intent(MyApplication.getmContext(), DetailApprovalCuti.class); Bundle b = new Bundle(); b.putParcelable("cuti", ApprovalCutiCardAdapter.allCuti.get(position)); b.putParcelable("process_cuti", ApprovalCutiCardAdapter.allCuti.get(position).getProcessCuti()); detailApprovalCutiIntent.putExtras(b); ((Activity)MyApplication.getmContext()).startActivityForResult(detailApprovalCutiIntent,1); } }); .... }Here's my code to finish the activity
btnReject.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { new AlertDialog.Builder(DetailApprovalCuti.this) .setTitle("Peringatan") .setMessage("Apakah anda yakin?") .setIcon(android.R.drawable.ic_dialog_alert) .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { setResult(1); finish(); } }).setNegativeButton(android.R.string.no, null).show(); } });