Rahul kuchhadia
Rahul kuchhadia

Reputation: 299

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?

Upvotes: 0

Views: 366

Answers (2)

Anjana
Anjana

Reputation: 933

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();

Upvotes: 0

Archie.bpgc
Archie.bpgc

Reputation: 24012

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

Or you can simply use:

getActivity().recreate();

Upvotes: 1

Related Questions