How to Handle Push Notification callback to move from Activity1 to Fragment1 then to Activity2

Viewed 58

Now I'm using pending intent to move between activities and to move for a fragment than to Activity, I'm passing fragment name and activity name as parameters in final activity. Is this the correct way of doing?

     if(!intent.getStringExtra("fragment").isNullOrEmpty()){
        var activityName = intent.getStringExtra("activityName")

        if(intent.getStringExtra("fragment").equals("HomeFragment"))
        {
            //First it will move to fragment
            displayFragment(R.id.navigation_home)
            navigation.menu.getItem(1).isChecked = true

            //After fragment is loaded 
            if(!activityName.isNullOrEmpty()){
                //Move to respective activity
            }
        }
        else
        {
            displayFragment(R.id.navigation_mystash)
            navigation.menu.getItem(2).isChecked = true
            //After fragment is loaded 
            if(!activityName.isNullOrEmpty()){
                //Move to respective activity
            }
        }

    }
0 Answers
Related