我有一個LibGDX遊戲,我剛剛注意到在某些時候,軟鍵不再隱藏。我不確定這是什麼時候發生或發生了什麼變化。當使用Proguard和縮小比例時不會隱藏在Android上的軟鍵
調查問題我發現它在調試模式下工作正常。然後我嘗試了關閉縮小的發佈版本,並且它也正常工作。
我試過調整各種設置,但無法獲得軟鍵隱藏打開縮小。
我在兩個不同的Android 6設備上發生了這種情況。
我真的不知道從哪裏開始看這個。有沒有其他人經歷過這個?
我的UI相關的代碼是在這裏:
private void setUpAndroidUi() {
// Do the stuff that initialize() would do for you
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
setKitKatVisibility();
} else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
setJellyBeanVisibility();
} else {
setStandardVisibility();
}
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
private void setStandardVisibility() {
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION);
}
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
private void setJellyBeanVisibility() {
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN);
}
@TargetApi(Build.VERSION_CODES.KITKAT)
private void setKitKatVisibility() {
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE);
}
Proguard的文件是
# ********** DEAFULT ANDROID SETUP *************
# This is a configuration file for ProGuard.
# http://proguard.sourceforge.net/index.html#manual/usage.html
# Optimizations: If you don't want to optimize, use the
# proguard-android.txt configuration file instead of this one, which
# turns off the optimization flags. Adding optimization introduces
# certain risks, since for example not all optimizations performed by
# ProGuard works on all versions of Dalvik. The following flags turn
# off various optimizations known to have issues, but the list may not
# be complete or up to date. (The "arithmetic" optimization can be
# used if you are only targeting Android 2.0 or later.) Make sure you
# test thoroughly if you go this route.
-optimizations !code/simplification/cast,!field/*,!class/merging/*
-optimizationpasses 5
-allowaccessmodification
-dontpreverify
# The remainder of this file is identical to the non-optimized version
# of the Proguard configuration file (except that the other file has
# flags to turn off optimization).
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable
-keepattributes *Annotation*
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService
# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
-keepclasseswithmembernames class * {
native <methods>;
}
# keep setters in Views so that animations can still work.
# see http://proguard.sourceforge.net/manual/examples.html#beans
-keepclassmembers public class * extends android.view.View {
void set*(***);
*** get*();
}
# We want to keep methods in Activity that could be used in the XML attribute onClick
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
-keepclassmembers class **.R$* {
public static <fields>;
}
# The support library contains references to newer platform versions.
# Don't warn about those in case this app is linking against an older
# platform version. We know about them, and they are safe.
-dontwarn android.support.**
# ********** END OF DEAFULT ANDROID SETUP *************
# ********** AMAZON RELATED STUFF *************
-dontwarn com.amazon.**
-keep class com.amazon.** {*;}
-keepattributes *Annotation*
-optimizations !code/allocation/variable
# ********** END AMAZON RELATED STUFF *************
# ********** WE WANT TO KEEP SERIALIZABLE STUFF FOR REFLECTION *********
-keep class * implements java.io.Serializable
-keepnames class * implements java.io.Serializable
-keepclassmembers class * implements java.io.Serializable{
public <init>();
public <init>(android.content.Context);
}
-keepclassmembers class * implements java.io.Serializable {
static final long serialVersionUID;
private static final java.io.ObjectStreamField[] serialPersistentFields;
!static !transient <fields>;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}
# ********** END WE WANT TO KEEP SERIALIZABLE STUFF FOR REFLECTION *********
# ********** OGURY *********
-keepattributes Signature
-keep class sun.misc.Unsafe { *; }
-keep class shared_presage.** { *; }
-keep class io.presage.** { *; }
-keepclassmembers class io.presage.** {
*;
}
-keepattributes *Annotation*
-keepattributes JavascriptInterface
-keepclassmembers class * {
@android.webkit.JavascriptInterface <methods>;
}
-dontwarn org.apache.commons.collections.BeanMap
-dontwarn java.beans.**
-keepclassmembers class * implements java.io.Serializable {
static final long serialVersionUID;
private static final java.io.ObjectStreamField[] serialPersistentFields;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}
# ********** OGURY BESPOKE
-keep class android.media.**
-dontwarn android.media.**
-dontnote android.media.**
# ********** END OGURY *********
# ********** LIBGDX **************
-verbose
-dontwarn android.support.**
-dontwarn com.badlogic.gdx.backends.android.AndroidFragmentApplication
-dontwarn com.badlogic.gdx.utils.GdxBuild
-dontwarn com.badlogic.gdx.physics.box2d.utils.Box2DBuild
-dontwarn com.badlogic.gdx.jnigen.BuildTarget*
-keepclassmembers class com.badlogic.gdx.backends.android.AndroidInput* {
<init>(com.badlogic.gdx.Application, android.content.Context, java.lang.Object, com.badlogic.gdx.backends.android.AndroidApplicationConfiguration);
}
-keepclassmembers class com.badlogic.gdx.physics.box2d.World {
boolean contactFilter(long, long);
void beginContact(long);
void endContact(long);
void preSolve(long, long);
void postSolve(long, long);
boolean reportFixture(long);
float reportRayFixture(long, float, float, float, float, float);
}
# ********** LIBGDX BESPOKE
-dontwarn java.awt.**
-dontwarn com.google.gwt.**
-keep,includedescriptorclasses class * implements com.badlogic.gdx.utils.Json*
# ********** END LIBGDX **************
# ********** GUAVA **********
-dontwarn javax.annotation.**
-dontwarn javax.inject.**
-dontwarn javax.xml.bind.**
-dontwarn sun.misc.Unsafe
# ********** END GUAVA **********
# ********** ADMOB **********
-keep,includedescriptorclasses public class com.google.android.gms.ads.** {
public *;
}
-keep,includedescriptorclasses public class com.google.ads.** {
public *;
}
# ********** END ADMOB **********
# ********** VUNGLE **********
-keep,includedescriptorclasses class com.vungle.** { public *; }
-keep,includedescriptorclasses class javax.inject.*
-keepattributes *Annotation*
-keepattributes Signature
-keep,includedescriptorclasses class dagger.*
# ********** END VUNGLE **********
# ********** BESPOKE **************
-keep class com.google.android.gms.** { *; }
-dontwarn com.google.android.gms.**
-keep class android.webkit.WebSettings
-dontwarn android.webkit.WebSettings
-keep,includedescriptorclasses class json.** {*; }
-keepnames class json.** {*; }
-keep class com.scribble.socketshared.messaging.IScrambledMessageReceiver
-dontwarn com.scribble.socketshared.messaging.IScrambledMessageReceiver
-dontwarn org.codehaus.**
-keep class com.facebook.ads.** { *; }
-dontwarn com.flurry.ads.**
-keep class com.flurry.android.** { *; }
-dontwarn com.flurry.android.**
-keep class com.inmobi.ads.** { *; }
-dontwarn com.inmobi.ads.**
-keep class com.inmobi.sdk.** { *; }
-dontwarn com.inmobi.sdk.**
-keep public @com.google.android.gms.common.util.DynamiteApi class * { *; }
# ********** END BESPOKE **************
請發佈您的proguard文件?以及爲什麼不使用啓用「沉浸模式」的AndroidApplicationConfiguration的useImmersiveMode標誌。 – Aryan
@AbhishekAryan Proguard補充說。我也在使用沉浸式標誌。爲了清楚起見,我決定明確地設置它。既沒有工作。 –