mirror of https://github.com/axmolengine/axmol.git
[android] Catches ‘NumberFormatException’ while invoking Integer.parseInt. (#16988)
* [android] Catches ‘NumberFormatException’ while invoking Integer.parseInt. * [android] Catches ‘NullPointerException’ while converting Integer to int in Cocos2dxActivity.hideVirtualButton.
This commit is contained in:
parent
2c2ed5c5f5
commit
a2603d70ef
|
@ -422,6 +422,8 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
|
|||
// use reflection to remove dependence of API level
|
||||
|
||||
Class viewClass = View.class;
|
||||
|
||||
try {
|
||||
final int SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION = Cocos2dxReflectionHelper.<Integer>getConstantValue(viewClass, "SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION");
|
||||
final int SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN = Cocos2dxReflectionHelper.<Integer>getConstantValue(viewClass, "SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN");
|
||||
final int SYSTEM_UI_FLAG_HIDE_NAVIGATION = Cocos2dxReflectionHelper.<Integer>getConstantValue(viewClass, "SYSTEM_UI_FLAG_HIDE_NAVIGATION");
|
||||
|
@ -440,6 +442,9 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
|
|||
"setSystemUiVisibility",
|
||||
new Class[]{Integer.TYPE},
|
||||
parameters);
|
||||
} catch (NullPointerException e) {
|
||||
Log.e(TAG, "hideVirtualButton", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -136,9 +136,12 @@ public class Cocos2dxHelper {
|
|||
parameters = new Object[]{Cocos2dxReflectionHelper.<String>getConstantValue(audioManagerClass, "PROPERTY_OUTPUT_FRAMES_PER_BUFFER")};
|
||||
final String strBufferSizeInFrames = Cocos2dxReflectionHelper.<String>invokeInstanceMethod(am, "getProperty", new Class[]{String.class}, parameters);
|
||||
|
||||
try {
|
||||
sampleRate = Integer.parseInt(strSampleRate);
|
||||
bufferSizeInFrames = Integer.parseInt(strBufferSizeInFrames);
|
||||
|
||||
} catch (NumberFormatException e) {
|
||||
Log.e(TAG, "parseInt failed", e);
|
||||
}
|
||||
Log.d(TAG, "sampleRate: " + sampleRate + ", framesPerBuffer: " + bufferSizeInFrames);
|
||||
} else {
|
||||
Log.d(TAG, "android version is lower than 17");
|
||||
|
|
Loading…
Reference in New Issue