The structure of activity and fragment is like :
Using NavigationDrawer.
MainActivity has a container for Fragment, in one container there should be have many fragment. After launch the app, default of fragment is fragment A.
Implement deeplink into MainActivity with Fragment B, how I can change the fragment from Fragment A(default) into Fragment B (destination).
Any help will helpfull :) Thanks
i.e class handle Applink
override fun onInitView() {
handleIntent()
}
private fun handleIntent() {
// ATTENTION: This was auto-generated to handle app links.
val intent = intent
val appLinkAction = intent.action
val appLinkData = intent.data
if (appLinkData != null) {
handleAppLinkIntent(appLinkData)
} else {
handleActivityIntent(intent)
}
}
protected abstract fun handleActivityIntent(intent: Intent)
protected abstract fun handleAppLinkIntent(appLinkData: Uri)
impl function
@Override
protected void handleActivityIntent(Intent intent) {
Bundle bundle = intent.getExtras();
if (bundle != null) {
switch (this.paramMainMenu) {
case Constants.ZERO:
this.goToProductList();
break;
case Constants.ONE:
this.goToFragmentA();
break;
case Constants.TWO:
this.goToFragmentB();
break;
case Constants.THREE:
this.goToFragmentC();
break;
}
}
}
@Override
protected void handleAppLinkIntent(Uri appLinkData) {
if(appLinkData.getQueryParameterNames().isEmpty()){
String path = appLinkData.getPath();
switch (path) {
case "/kfc/food/price/outofstock":
this.paramMainMenu = Constants.ONE;
break;
case "/food/price/qty":
this.paramMainMenu = Constants.THREE;
break;
case "/price/unbuyable":
this.paramMainMenu = Constants.TWO;
break;
case "/price":
this.paramMainMenu = Constants.ZERO;
break;
case "/food/price":
this.paramMainMenu = Constants.ZERO;
break;
case "/a/food/item":
this.paramMainMenu = Constants.ZERO;
break;
case "/":
this.paramMainMenu = Constants.ZERO;
break;
}
}
}