在Samsung Galaxy上调用RingTonePreference时收到以下消息(一切在其他手机上运行正常):
java.lang.RuntimeException: Unable to start activity ComponentInfo{android/com.a
ndroid.internal.app.RingtonePickerActivity}: java.lang.NullPointerException
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
at android.app.ActivityThread.access$2300(ActivityThread.java:125)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:123)
at android.app.ActivityThread.main(ActivityThread.java:4627)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:521)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:85
8)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.NullPointerException
at com.android.internal.app.RingtonePickerActivity.onPrepareListView(RingtonePic
kerActivity.java:252)
at com.android.internal.app.AlertController$AlertParams.createListView(AlertCont
roller.java:909)
at com.android.internal.app.AlertController$AlertParams.apply(AlertController.ja
va:824)
at com.android.internal.app.AlertActivity.setupAlert(AlertActivity.java:73)
at com.android.internal.app.RingtonePickerActivity.onCreate(RingtonePickerActivi
ty.java:226)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
... 11 more
更新:以下是调用方式:
<RingtonePreference android:key="pref_notification_ringTone"
android:title="@string/pref_notification_Ringtone"
android:ringtoneType="notification" android:showDefault="true"
android:showSilent="false" />
PS:我知道已经提出了类似的问题,但没有给出答案(https://stackoverflow.com/questions/5428768/notification-or-alarm-sound-picker-crash-on-galaxy-s/5872352#5872352)
答案 0 :(得分:3)
通过在定义中设置“showSilent = true”来解决此问题,这显然是Galaxy S特有的错误。