onConfigurationChanged не работает для API17 - PullRequest
0 голосов
/ 22 марта 2020

Я хотел бы вызвать что-то, если бы таблица была наклонена от портрета к пейзажу или наоборот.
Однако onConfigurationChanged никогда не срабатывает. Я прочитал несколько вопросов, поднятых несколько лет назад от поклонников переполнения стека, но ни один не работает. Например,
, добавьте android:configChanges="orientation|screenSize" внутри Android. ниже AndroidManifest. xml, журналы приложений и отладки,
спасибо

D/ViewRootImpl@d3690a3[MainActivity]: Relayout returned: old=[0,0][1920,1200] new=[0,0][1920,1200] 
    result=0x7 surface={true 3874265088} changed=true
D/OpenGLRenderer: eglCreateWindowSurface = 0xe8985120, 0xe6ec9808
D/ScrollView:  onsize change changed 
E/ViewRootImpl: sendUserActionEvent() returned.
I/Choreographer: Skipped 51 frames!  The application may be doing too much work on its main thread.
D/ViewRootImpl@d3690a3[MainActivity]: MSG_RESIZED_REPORT: frame=[0,0][1920,1200] ci=[0,36][0,72] vi= 
    [0,36][0,72] or=2
D/ViewRootImpl@d3690a3[MainActivity]: MSG_WINDOW_FOCUS_CHANGED 1 1
D/InputMethodManager: prepareNavigationBarInfo() DecorView@15f6fa0[MainActivity]
D/InputMethodManager: getNavigationBarColor() -855310
D/InputMethodManager: prepareNavigationBarInfo() DecorView@15f6fa0[MainActivity]
getNavigationBarColor() -855310
V/InputMethodManager: Starting input: tba=com.example.android.predictiongua ic=null mNaviBarColor 
    -855310 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false
D/InputMethodManager: startInputInner - Id : 0
I/InputMethodManager: startInputInner - mService.startInputOrWindowGainedFocus
D/InputTransport: Input channel constructed: fd=76
Input channel destroyed: fd=77
V/item: 7
V/item: 3
V/item: 8
<application
    android:allowBackup="true"
    android:icon="@mipmap/android_icon"
    android:label="xxxxxx"
    android:roundIcon="@mipmap/ic_launcher_round"
    android:supportsRtl="true"
    android:configChanges="screenSize|keyboardHidden|orientation"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
    applicationId "com.example.android.xxxxxx"
    minSdkVersion 17
    targetSdkVersion 29
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
androidTestImplementation('com.android.support.test.espresso:espresso-core:3.0.2', {
    exclude group: 'com.android.support', module: 'support-annotations'
})

//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'

implementation 'net.cachapa.expandablelayout:expandablelayout:2.9.2'
implementation 'com.github.aakira:expandable-layout:1.6.0@aar'
}

1 Ответ

0 голосов
/ 22 марта 2020

Вам следует поместить следующую строку между тегом «активность», а не между «приложением», попробуйте использовать его следующим образом:

<application
    android:allowBackup="true"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">

    <activity
        android:name=".MainActivity"
        android:configChanges="screenSize|keyboardHidden|orientation" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>
...