在释放模式下按HOME键后,重新打开了登录度



我的问题是,如果我在应用程序中打开任何活动,然后按Home键按钮。然后重新打开应用程序,则打开登录活动,而不是打开当前活动,则用户实际用户实际用户in。

这仅在发布模式下发生。

应用清单文件

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.example.test">
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.CAMERA" />
    <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
    <uses-feature android:name="android.hardware.camera" />
    <uses-feature android:name="android.hardware.camera.autofocus" />
    <application
        android:name="com.example.TestApp"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/AppTheme"
        android:networkSecurityConfig="@xml/network"
        tools:node="merge">
        <activity android:name=".pages.assitance.question.QuestionAnswerActivity" android:screenOrientation="portrait"></activity>
        <activity android:name=".pages.tripdetails.TripDetailActivity" android:screenOrientation="portrait"/>
        <activity android:name=".pages.profile.EditProfileActivity" android:screenOrientation="portrait"/>
        <activity android:parentActivityName=".pages.main.MainActivity" android:name=".pages.QrActivity" android:screenOrientation="portrait"/>
        <activity android:name=".pages.profile.ProfileActivity" android:screenOrientation="portrait"/>
        <activity android:name=".pages.main.MainActivity" android:screenOrientation="portrait"/>
        <activity android:name=".pages.login.LoginActivity" android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <service android:name=".core.location.TestService" />
        <service
            android:name=".TestService"
            android:exported="false">
            <intent-filter>
                <action android:name="com.google.firebase.MESSAGING_EVENT" />
            </intent-filter>
        </service>
    </application>
</manifest>

和gradle清单文件

apply plugin: 'com.android.application'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'io.fabric'
android {

    compileSdkVersion 28
    defaultConfig {
        applicationId "com.example.test"
        minSdkVersion 21
        targetSdkVersion 28
        versionCode 2
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            debuggable true
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.config
        }
        debug {
//            minifyEnabled true
//            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}
dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation project(':assi')
    implementation project(':location')
    implementation project(':notification')
    implementation 'androidx.appcompat:appcompat:1.0.0-beta01'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    implementation 'com.google.android.material:material:1.0.0-rc01'
    implementation 'android.arch.lifecycle:extensions:1.1.1'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0-beta01'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
    //butterknife
    implementation 'com.jakewharton:butterknife:10.1.0'
    annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'
    //picasso
    implementation 'com.squareup.picasso:picasso:2.5.2'
    //lottie animation
    implementation 'com.airbnb.android:lottie:3.0.0'
    //qr
    implementation 'me.dm7.barcodescanner:zxing:1.9'
    //location
    implementation 'com.google.android.gms:play-services-location:16.0.0'
    // RxJava
    implementation 'io.reactivex.rxjava2:rxjava:2.1.9'
    implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
    // Retrofit and OkHttp
    // OkHttp interceptors for logging
    implementation 'com.squareup.retrofit2:retrofit:2.4.0'
    implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
    implementation 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
    implementation 'com.squareup.okhttp3:okhttp:3.10.0'
    implementation 'com.squareup.okhttp3:okhttp-urlconnection:3.0.1'
    implementation 'com.squareup.okhttp3:logging-interceptor:3.4.1'
    //room
    implementation 'androidx.room:room-runtime:2.0.0-beta01'
    annotationProcessor 'androidx.room:room-compiler:2.0.0-beta01'
    // use kapt for Kotlin
    //phone number validation
    implementation 'com.googlecode.libphonenumber:libphonenumber:8.2.0'
    //socket.io
    implementation('io.socket:socket.io-client:1.0.0') {
        // excluding org.json which is provided by Android
        exclude group: 'org.json', module: 'json'
    }
    //library for rating
    implementation 'com.github.ome450901:SimpleRatingBar:1.4.2'
    //firebase
    implementation 'com.google.firebase:firebase-core:16.0.8'
    //crashlytics
    releaseImplementation 'com.crashlytics.sdk.android:crashlytics:2.10.0'
    //firebase push notification
    implementation 'com.google.firebase:firebase-messaging:18.0.0'
}
repositories {
    mavenCentral()
}
apply plugin: 'com.google.gms.google-services'

如果我在调试或发布模式下从Android Studio运行该应用程序,则正常工作

它仅在我生成版本apk

时才发生

有什么想法?

如果您只想打开一次登录活动,何时登录并重新打开应用程序,您想打开家庭活动,然后保存应用程序的状态或保存登录名您将在飞溅上比较的共享偏好中的状态,而不是决定您应该在哪里进行活动或登录活动。

在调用登录活动的登录功能后将获得成功时,请执行此操作:

 SharedPreferences pref = this.getSharedPreferences ("Login",0);
 Editor editor = pref.Editor();
 editor.putBoolean("login",true)
 editor.commit();

在飞溅屏幕代码中执行此操作:

Boolean loggedIn = SplashScreen.this.getSharedPreferences("Login",0) .getBoolean 
                   ("login",false);
if(loggedIn) {
startActivity(new Intent(SplashScreen.this,HomeActivity.class));
finish();
} else {
startActivity(new Intent(SplashScreen.this,LoginActivity.class));
finish();
}

最新更新