Closed PSDroid2022 closed 2 years ago
This is clearly nonsense. The current docs show that android.os.Bundle
(API level 1) inherits from android.os.BaseBundle
(API level 21), which cannot be true for API levels less than 21. The answer is that Bundle
contains getInt()
and putint()
in API levels less than 21, along with several other methods which the current docs say are in BaseBundle
. Here are the sources for getInt()
in Bundle.java
for API level 19. If this were not so, the android build tools would pick it up.
/**
* Returns the value associated with the given key, or 0 if
* no mapping of the desired type exists for the given key.
*
* @param key a String
* @return an int value
*/
public int getInt(String key) {
unparcel();
return getInt(key, 0);
}
/**
* Returns the value associated with the given key, or defaultValue if
* no mapping of the desired type exists for the given key.
*
* @param key a String
* @param defaultValue Value to return if key does not exist
* @return an int value
*/
public int getInt(String key, int defaultValue) {
unparcel();
Object o = mMap.get(key);
if (o == null) {
return defaultValue;
}
try {
return (Integer) o;
} catch (ClassCastException e) {
typeWarning(key, o, "Integer", defaultValue, e);
return defaultValue;
}
}
Thanks, it seems a false positive!
We confirm a compatibility issue which might threaten the robustness of your app and give a detailed suggestion for you.
In ''org.billthefarmer.gurgle.Gurgle", you invoke the framework API "<android.os.BaseBundle: int getInt(java.lang.String)>" in "onRestoreInstanceState" method as shown in following. But actually, this method is introduced after API level 21 (https://developer.android.google.cn/reference/kotlin/android/os/BaseBundle?hl=en#getint_1).
So when the app try to invoke this API on devices before API level 21, your app will run with an unpredictable results. So we suggest you add an "if(SDK_INT >= 21)" to fix this potential issue.
Android device
install app on devices with API 19, open Gurgle with crash.