Reputation: 47
I want to prevent my app from the rotation, but I don't want to specify the screen Orientation in every activity tag in the manifest file instead I want to define it only once in my application which should work for the whole app. Is there any way to do that? Or I need to specify this in every activity?
Upvotes: 0
Views: 69
Reputation: 5550
there is a way, you can create baseActivity and make all activities extend it.
open class BaseActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
}
}
class MainActivity : BaseActivity() {
}
Upvotes: 0