我为团结游戏制作了一个 java插件,可以在屏幕解锁时重新打开音乐。在 Android 2.3.3 上它没有问题,但我抱怨它在 Android 2.2 下崩溃游戏。 我没有设备来测试这个,但是有很多抱怨,所以有些事情是错误的。
有人遇到过同样的问题吗?
Java插件只包含一个 BroadcastReceiver ,它向一起发送消息:
public void onReceive(Context arg0, Intent intent) {
if(intent.getAction().equals(Intent.ACTION_USER_PRESENT))
{
try {
UnityPlayer.UnitySendMessage("Camera", "OnUserReturned", null);
} catch (UnsatisfiedLinkError e) {
Log.e("UNITY_SEND_MSG", e.getMessage());
e.printStackTrace();
}
}
}
在 Manifest:
中<receiver android:name="UserPresentReceiver">
<intent-filter>
<action android:name="android.intent.action.USER_PRESENT" />
</intent-filter>
</receiver>
我无法弄清楚是否导致崩溃,我无法在Android 2.3下重现它们。有人可以帮我解决这个问题,还是建议另一种方法可以在锁定屏幕下停止音乐并在锁定屏幕消失后重新启动它?
提前致谢
编辑: 堆栈跟踪:
01-01 02:29:31.036: WARN/dalvikvm(8970): JNI WARNING: received null jstring (Check_GetStringUTFChars)
01-01 02:29:31.036: INFO/dalvikvm(8970): "main" prio=5 tid=1 NATIVE
01-01 02:29:31.036: INFO/dalvikvm(8970): | group="main" sCount=0 dsCount=0 s=N obj=0x4001d928 self=0xccd8
01-01 02:29:31.036: INFO/dalvikvm(8970): | sysTid=8970 nice=0 sched=0/0 cgrp=default handle=-1345017812
01-01 02:29:31.036: INFO/dalvikvm(8970): | schedstat=( 3072569000 2291321000 12753 )
01-01 02:29:31.036: INFO/dalvikvm(8970): at com.unity3d.player.UnityPlayer.UnitySendMessage(Native Method)
01-01 02:29:31.036: INFO/dalvikvm(8970): at com.angrymobgames.userpresent.UserPresentReceiver.onReceive(UserPresentReceiver.java:19)
01-01 02:29:31.036: INFO/dalvikvm(8970): at android.app.ActivityThread.handleReceiver(ActivityThread.java:2810)
01-01 02:29:31.036: INFO/dalvikvm(8970): at android.app.ActivityThread.access$3200(ActivityThread.java:125)
01-01 02:29:31.036: INFO/dalvikvm(8970): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2083)
01-01 02:29:31.036: INFO/dalvikvm(8970): at android.os.Handler.dispatchMessage(Handler.java:99)
01-01 02:29:31.036: INFO/dalvikvm(8970): at android.os.Looper.loop(Looper.java:123)
01-01 02:29:31.036: INFO/dalvikvm(8970): at android.app.ActivityThread.main(ActivityThread.java:4627)
01-01 02:29:31.036: INFO/dalvikvm(8970): at java.lang.reflect.Method.invokeNative(Native Method)
01-01 02:29:31.036: INFO/dalvikvm(8970): at java.lang.reflect.Method.invoke(Method.java:521)
01-01 02:29:31.036: INFO/dalvikvm(8970): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
01-01 02:29:31.036: INFO/dalvikvm(8970): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
01-01 02:29:31.036: INFO/dalvikvm(8970): at dalvik.system.NativeStart.main(Native Method)
01-01 02:29:31.036: ERROR/dalvikvm(8970): VM aborting