铃声选择器不工作 [英] ringtone picker is not working

查看:195
本文介绍了铃声选择器不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用这个LIB android.v4。preference。片段,随着铃声preference有问题,低于code工作高超ICS及以下版本的手机,但它推出的重复铃声对话框ICS及以上的手机,也就是说,它推出2铃声preference对话框。

i'm using this lib android.v4.preference.fragment, having issue with ringtone preference, the below code works superb for ICS and below version phones, but it launches duplicate ringtone dialog for ICS and above phones, i.e it launches 2 ringtone preference dialogs.

铃声pref.setOn preferenceClickListener(新在preferenceClickListener(){

ringtonepref.setOnPreferenceClickListener(new 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;
}

我管这样的活动的结果。

i'm handling like this in activity result

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;

我试过另一种方式来比较,即设备ICS及以上的其他上市默认的允许自定义的意图,但对于果冻豆和其他设备我没有收到该事件在preferenceChangeListener ,现在我很困惑的任何帮助。

i tried another way to compare the devices i.e ICS and above launch the default one else allow custom intent, but for Jelly bean and other devices i'm not getting the event to OnPreferenceChangeListener, now i'm confused any help.

感谢

推荐答案

这实际上是对图书馆工作流程错误,并有超过解决方法是,你可以找到的这里

This is actually a workflow bug on the library and there are more than workaround for it that you can find here.

这篇关于铃声选择器不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆