나는이 벨소리 android.v4.preference.fragment을 사용하고 있습니다. 벨소리 환경 설정과 관련된 문제가 있습니다. 아래 코드는 ICS 및 그 이하 버전의 전화기에서 훌륭하게 작동하지만 ICS 이상 전화기에서 중복되는 벨소리 대화 상자를 실행합니다. 벨소리 환경 설정 대화 상자.벨소리 선택기가 작동하지 않습니다
ringtonepref.setOnPreferenceClickListener (새 OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference arg0) {
// TODO Auto-generated method stub
{
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getActivity());
String path = settings.getString("prefnotificationTone", "content://settings/system/notification_sound");
Uri uri = !TextUtils.isEmpty(path) ? Uri.parse(path) : null;
Intent intent = new Intent(RingtoneManager.ACTION_RINGTONE_PICKER);
//intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_NOTIFICATION);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_TYPE, RingtoneManager.TYPE_ALL);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_EXISTING_URI, uri);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_SILENT, true);
intent.putExtra(RingtoneManager.EXTRA_RINGTONE_SHOW_DEFAULT, true);
getActivity().startActivityForResult(intent, 1000);
}
return true;
}
나는 장치가 ICS를, 즉 및 출시 위 비교하는 또 다른 방법을 시도
case 1000:
if (resultCode == Activity.RESULT_OK)
{
Uri uri = data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this);
Editor editor = settings.edit();
editor.putString("prefnotificationTone", uri == null ? "": uri.toString());
editor.commit();
}
else
{
}
break;
활동 결과에 다음과 같이 처리하고 있습니다 다른 하나는 사용자 정의 인 텐트를 허용하지만 Jelly bean 및 기타 장치에 대해서는 OnPreferenceChangeListener
으로 이벤트가 전달되지 않습니다. 이제는 어떤 도움도 혼동 스럽습니다.
감사합니다.
[this] (http://developer.android.com/reference/android/preference/RingtonePreference.html) 및 [this] (https://github.com/kolavar/android-support-v4)를 찾을 수 있습니다. -preferencefragment/issues/1) 링크가 유용합니다. 그런데 PreferenceFragment가 지원 라이브러리에서 지원되지 않기 때문에 API 레벨 <11, 및 API 레벨 11의 PreferenceFragment에 대해 PreferenceActivity를 실행하는 다른 접근 방식을 사용하고 있습니다. –
안녕하세요, 좋은 생각입니다.하지만 조각, 즉 뷰 페이지가 있습니다. viewpager에서 활동을 시작하는 것이 가능하지 않을 수 있습니까? 제발 마음에 들지 않으면 샘플 코드를 제공 할 수 있습니까? – Naruto
안녕하세요 @DerGolem, 어떤 도움을 기다리고 있습니다. viewfragment를 사용하고 있습니다. 그래서 우리는 그 안의 활동을 바로 사용할 수 없습니까? 사전에 감사합니다 – Naruto