I want to pass data from MainActivity to Fragment i'm using this for my action
switch (txt.getText().toString()){
       case "Jumlah(Tinggi-Rendah)":
         dialog.dismiss();
         cond = "desc";
         by = "jumlah";
         Log.e("By1 : ", ""+by );
         Intent intent = new Intent("KEY");
         sendBroadcast(intent);
         return;
and this is my get String
public String getDataAkun(){
   return idakun;
}
public String getDataBy(){
    return by;
}
and this is my script in my fragment
MainActivity activity = (MainActivity) getActivity();
    idakun = activity.getDataAkun();
    by = activity.getDataBy();
this is my broadcast
private BroadcastReceiver updateProfileBroadcast = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {
        //Fire your event
        list_transaksi();
        Toast.makeText(getContext(),"huft :"+by+" - "+idakun,Toast.LENGTH_LONG).show();
    }
};
when i run my action just "idakun" who get the data but "by" is returning null
enter image description here im new on android programming so if there any help please ...
 
     
    