How can I detect screen rotation?

前端 未结 3 1077
轻奢々
轻奢々 2021-01-17 10:25

is it possible to detect screen rotation? I mean - rotation only, which is clearly distinguishable from activity initialization from another activity?

The onXxx meth

3条回答
  •  轮回少年
    2021-01-17 10:43

    Manifest:

    
    

    Activity:

    @Override
    public void onConfigurationChanged(Configuration newConfig)
    {
        Log.d("tag", "config changed");
        super.onConfigurationChanged(newConfig);
    
        int orientation = newConfig.orientation;
        if (orientation == Configuration.ORIENTATION_PORTRAIT)
            Log.d("tag", "Portrait");
        else if (orientation == Configuration.ORIENTATION_LANDSCAPE)
            Log.d("tag", "Landscape");
        else
            Log.w("tag", "other: " + orientation);
    
        ....
    }
    

    try this link also

    How do I detect screen rotation

提交回复
热议问题