以下代码在某些设备上不断崩溃(立即关闭铃声选择器对话框),在大多数设备上它按预期工作。我没有设法找到它崩溃的设备的共同标准。
如果有人可以帮我解决这个问题,我真的很开心。 BTW:Logcat绝对没有显示任何内容。没有错误。这是代码
protected void chooseRingtone() {
final Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, false);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_ALL);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TITLE, getString(R.string.choose_ringtone));
if (ringtoneURI != null) {
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, ringtoneURI);
}
else {
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, (Uri) null);
}
startActivityForResult(intent, RINGTONE_RESULT);
}
@Override
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
if (resultCode == RESULT_OK && requestCode == RINGTONE_RESULT) {
ringtoneURI = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
if (ringtoneURI != null) {
try {
ringtoneString = RingtoneManager.getRingtone(this, ringtoneURI).getTitle(this);
} catch (final Exception e) {
ringtoneString = "unknown";
}
ringtone.setText(ringtoneString);
}
}
}
Manifest看起来像这样:
<uses-sdk
android:maxSdkVersion="17"
android:minSdkVersion="8"
android:targetSdkVersion="8"
/>