I have a question.I wanna use the app in landscape and portrait mode but I need information about when I rotate the device portrait to landscape, the app split to 2 fragments.
I research many websites but I haven't necessary infos about that. How can I do that?
EDIT
productFlavors {
phone {
applicationId "packageName.app.phone"
buildConfigField 'boolean', 'IsPhone', 'true'
versionName ""
}
tablet {
applicationId "packageName.app.tablet"
buildConfigField 'boolean', 'IsPhone', 'false'
versionName ""
}
}
I split my apk.I have a phone.apk and tablet.apk.
If you really want to know when the device rotate you can try something like this.
@Override
public void onConfigurationChanged(Configuration config) {
super.onConfigurationChanged(config);
if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) {
// "landscape"
} else if (config.orientation == Configuration.ORIENTATION_PORTRAIT){
//"portrait"
}
}
But usually you are not supposed to do this. You just need to provide one layout for portrait
and another one for lanscape
and then let the layout load the required Fragments.
In the case of to separate phone.apk and a tablet.apk each apk should be shipped, using gradle, with its respective set of layout.