Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8093161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T20:26:39+00:00 2026-06-05T20:26:39+00:00

I use RingtonePreference and would like to use default notification sound as the default

  • 0

I use RingtonePreference and would like to use default notification sound as the default preference value. To achieve this I have followed advice in: RingtonePreference Default value

Sadly, in effect I got an InflateException that I cannot get rid of in any way. Is it a bug in android, my phone or am I doing something wrong?

My OnCreate method in MyPreferenceActivity class:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preferences);
}

Relevant fragment of my preferences.xml:

<RingtonePreference
      android:key="ringtone_preference"
      android:ringtoneType="notification"
      android:showDefault="true"
      android:showSilent="true"
      android:defaultValue="content://settings/system/notification_sound"
      android:title="Notification sound"
      android:summary=""
      />

LogCat of the exception:

06-06 22:44:07.697: E/ActivityThread(21031): Failed to inflate
06-06 22:44:07.697: E/ActivityThread(21031): android.view.InflateException: Binary XML file line #17: Error inflating class java.lang.reflect.Constructor
06-06 22:44:07.697: E/ActivityThread(21031):    at android.preference.GenericInflater.createItem(GenericInflater.java:397)
06-06 22:44:07.697: E/ActivityThread(21031):    at android.preference.GenericInflater.onCreateItem(GenericInflater.java:417)
06-06 22:44:07.697: E/ActivityThread(21031):    at android.preference.GenericInflater.createItemFromTag(GenericInflater.java:428)
06-06 22:44:07.697: E/ActivityThread(21031):    at android.preference.GenericInflater.rInflate(GenericInflater.java:481)
06-06 22:44:07.697: E/ActivityThread(21031):    at android.preference.GenericInflater.rInflate(GenericInflater.java:493)
06-06 22:44:07.697: E/ActivityThread(21031):    at android.preference.GenericInflater.inflate(GenericInflater.java:326)
06-06 22:44:07.697: E/ActivityThread(21031):    at android.preference.GenericInflater.inflate(GenericInflater.java:263)
06-06 22:44:07.697: E/ActivityThread(21031):    at android.preference.PreferenceManager.inflateFromResource(PreferenceManager.java:269)
06-06 22:44:07.697: E/ActivityThread(21031):    at android.preference.PreferenceActivity.addPreferencesFromResource(PreferenceActivity.java:1457)
06-06 22:44:07.697: E/ActivityThread(21031):    at com.stanwise.timespacereminder.TSRPreferenceActivity.onCreate(TSRPreferenceActivity.java:44)
06-06 22:44:07.697: E/ActivityThread(21031):    at android.app.Activity.performCreate(Activity.java:4465)
06-06 22:44:07.697: E/ActivityThread(21031):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
06-06 22:44:07.697: E/ActivityThread(21031):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2034)
06-06 22:44:07.697: E/ActivityThread(21031):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2105)
06-06 22:44:07.697: E/ActivityThread(21031):    at android.app.ActivityThread.access$600(ActivityThread.java:133)
06-06 22:44:07.697: E/ActivityThread(21031):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158)
06-06 22:44:07.697: E/ActivityThread(21031):    at android.os.Handler.dispatchMessage(Handler.java:99)
06-06 22:44:07.697: E/ActivityThread(21031):    at android.os.Looper.loop(Looper.java:137)
06-06 22:44:07.697: E/ActivityThread(21031):    at android.app.ActivityThread.main(ActivityThread.java:4586)
06-06 22:44:07.697: E/ActivityThread(21031):    at java.lang.reflect.Method.invokeNative(Native Method)
06-06 22:44:07.697: E/ActivityThread(21031):    at java.lang.reflect.Method.invoke(Method.java:511)
06-06 22:44:07.697: E/ActivityThread(21031):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
06-06 22:44:07.697: E/ActivityThread(21031):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
06-06 22:44:07.697: E/ActivityThread(21031):    at dalvik.system.NativeStart.main(Native Method)
06-06 22:44:07.697: E/ActivityThread(21031): Caused by: java.lang.reflect.InvocationTargetException
06-06 22:44:07.697: E/ActivityThread(21031):    at java.lang.reflect.Constructor.constructNative(Native Method)
06-06 22:44:07.697: E/ActivityThread(21031):    at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
06-06 22:44:07.697: E/ActivityThread(21031):    at android.preference.GenericInflater.createItem(GenericInflater.java:383)
06-06 22:44:07.697: E/ActivityThread(21031):    ... 23 more
06-06 22:44:07.697: E/ActivityThread(21031): Caused by: java.lang.NullPointerException
06-06 22:44:07.697: E/ActivityThread(21031):    at android.preference.MultiSelectListPreference.onGetDefaultValue(MultiSelectListPreference.java:211)
06-06 22:44:07.697: E/ActivityThread(21031):    at android.preference.Preference.<init>(Preference.java:260)
06-06 22:44:07.697: E/ActivityThread(21031):    at android.preference.DialogPreference.<init>(DialogPreference.java:69)
06-06 22:44:07.697: E/ActivityThread(21031):    at android.preference.DialogPreference.<init>(DialogPreference.java:90)
06-06 22:44:07.697: E/ActivityThread(21031):    at android.preference.MultiSelectListPreference.<init>(MultiSelectListPreference.java:49)
06-06 22:44:07.697: E/ActivityThread(21031):    ... 26 more

I also tried inserting a string DEFAULT_NOTIFICATION_URI instead of content://settings/system/notification_sound, but without any success. After removing the android:defaultValue field completely, everything works fine apart from the fact, that default value of my preference is Silent ringtone instaed of the default notification sound, which is unacceptable for me.

I have searched everywhere and cannot find a solution to this problem. If nothing else works, I will use a hack posted here: https://stackoverflow.com/a/4298638/1265432, but I would like to solve this properly.

EDIT: Problem exists on both my CM9 Motorola Defy and in Emulators of 4.0.4 (API 15) and 2.1 (API 7), so I think the phone is not a problem. Bug, or am I doing something wrong?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T20:26:41+00:00Added an answer on June 5, 2026 at 8:26 pm

    I filed a bug report for Android here: http://code.google.com/p/android/issues/detail?id=33220

    In the meantime, I use the following workaround, which I found cleaner than the one linked in the question. I modified OnCreate method of MyPreferenceActivity to this:

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    
         Uri notificationSound = Uri.parse(PreferenceManager.getDefaultSharedPreferences(this)
        .getString("ringtone_preference", System.DEFAULT_NOTIFICATION_URI.toString()));
        if (notificationSound.equals(System.DEFAULT_NOTIFICATION_URI)) {
            PreferenceManager.getDefaultSharedPreferences(this).edit()
                .putString("ringtone_preference", System.DEFAULT_NOTIFICATION_URI.toString())
                .commit();
        }
    
        addPreferencesFromResource(R.xml.preferences);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

use strict; use Time::HiRes qw[gettimeofday tv_interval]; my $start_index = int(rand(50))+100;#this value is arbitrary for
use this code, in the Preferences activity, to know when the reset preference has
Use default: <input type=radio name=restype value=resdef onfocus=document.getElementById('resupload').disabled = true; document.getElementById('resadres').disabled = true; checked=checked /><br
Use trap to capture signals like this: i=-1;while((++i<33)); do trap echo $i >> log.txt
I use AppEngine to host an Eclipse update site. I would like to keep
use Modern::Perl; use Algorithm::Permute; use List::AllUtils qw/uniq/; find_perms(1151); sub find_perms { my ($value) =
Use Elixir and have two entities -- Voter and Candidate -- with many to
use javascript or other method ? have any recommendation?
Use case: You have 2-3 files displayed in your MacVim window(s). You press ctrl+Q
Use scenario is pretty simple: I have a desktop only application that could be

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.