简体   繁体   中英

how to call same activity from Intent Android?

How to Call Same Activity From Intent in firebase onChildChange ?

@Override
public void onChildChanged(@NonNull DataSnapshot dataSnapshot, @Nullable String s) {
     try {
        Intent i= new Intent(PlaceholderFragment.this,PlaceholderFragment.this);
     }
     catch (Exception e){}
}

How to Call Same Activity From Intent?

Intent i = new Intent(getActivity, YourActivity.class);
i.startActivity();

Or you can simply use:

getActivity().recreate();

You can call same fragment from itself as follows.

PlaceholderFragment newFragment = new PlaceholderFragment();

FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
fragmentTransaction.add(R.id.layoutContainer, newFragment , "New Fragment");
fragmentTransaction.addToBackStack("New Fragment");
fragmentTransaction.commit();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM