title: How to unlock settings with in app purchases
body: <p>I have an app that I am going to release for free, however I would like to include in app purchases to unlock the advanced settings. I've done some searching for tutorials on this topic, but only find information on settings for purchasing and nothing that is programmatically geared. I'm not trying to make this a broad question about how IAP works, but how to apply it to settings. Possibly some code will help. The meat of it is in the last code snippet, preferences.xml. I've included everything so you can see how I have the preferences set up.</p>
  
  <p>MainActivity.java</p>
  
  <p>Waits for case "R.id.preferences".</p>
  
  <pre><code>@Override
  public boolean onCreateOptionsMenu(Menu menu)
  {
      super.onCreateOptionsMenu(menu);
      getMenuInflater().inflate(R.menu.settings_menu, menu);
  
      return true;
  }
  
  @Override
  public boolean onOptionsItemSelected(MenuItem item)
  {
      switch(item.getItemId())
      {
          case R.id.about:
              Intent about = new Intent("com.app.ABOUT");
              startActivity(about);
              break;
          case R.id.preferences:
              Intent preferences = new Intent("com.app.PREFERENCES");
              startActivity(preferences);
              break;
          case R.id.exit:
              monitor.pauseSensor(listener);
              finish();
              break;
      }
  }
  </code></pre>
  
  <p>settings_menu.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;menu xmlns:android="http://schemas.android.com/apk/res/android" &gt;
  &lt;item 
      android:title="@string/action_settings"
      android:id="@+id/preferences"/&gt;
  
  &lt;item 
      android:title="About"
      android:id="@+id/about"/&gt;
  
  &lt;item 
      android:title="Exit"
      android:id="@+id/exit"/&gt;
  &lt;/menu&gt;
  </code></pre>
  
  <p>preferences.java</p>
  
  <pre><code>public class Preferences extends PreferenceActivity
  {
      @Override
      protected void onCreate(Bundle savedInstanceState)
      {
      super.onCreate(savedInstanceState);
  
      getFragmentManager().beginTransaction().replace(android.R.id.content, new PreferencesFragment()).commit();
      }
  
      public static class PreferencesFragment extends PreferenceFragment
      {
          @Override
          public void onCreate(final Bundle savedInstanceState)
          {
              super.onCreate(savedInstanceState);
              addPreferencesFromResource(R.xml.preferences);
          }
      }
  }
  </code></pre>
  
  <p>preferences.xml</p>
  
  <p>This is where I want to apply the paid options. In this example, there are three paid settings. I originally thought that I could just have two different preferences.xml files and use one or the other based on if the paid settings were purchased or not. However, this will be difficult as I would like the settings to be purchased individually or in any combination. I have many more than just three paid for settings and creating the different combinations of xml files doesn't seem ideal or scalable. Is there a better way of solving this?</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" &gt;
  &lt;PreferenceCategory android:title="Basic Settings"&gt;   
      &lt;com.app.custPref
          android:title="Free Pref 1"
          android:key="freePref1"
          android:defaultValue="15"/&gt;
  &lt;/PreferenceCategory&gt;
  &lt;PreferenceCategory android:title="Advanced Settings"&gt;
      &lt;com.app.custPref
          android:title="Free Pref 2"
          android:key="freePref2"
          android:defaultValue="5"/&gt;
      &lt;PreferenceScreen
          android:title="Paid Settings"
          android:key="paidSetting"
          android:persistent="false"&gt;
          &lt;PreferenceCategory android:title="Paid Settings Category 1"&gt;
              &lt;EditTextPreference
                  android:title="Paid Settings 1"
                  android:key="paidSetting1"
                  android:summary="This setting is only available if you have purchased it"&gt;
              &lt;/EditTextPreference&gt;
          &lt;/PreferenceCategory&gt;
          &lt;PreferenceCategory android:title="Paid Settings Category 2"&gt;
              &lt;CheckBoxPreference 
                  android:title="Paid Settings 2"
                  android:summary="This is the second paid setting that can be purchased."
                  android:key="paidSetting2"
                  android:defaultValue="false"/&gt;
              &lt;EditTextPreference
                  android:title="Paid Settings 3"
                  android:key="paidSetting3"
                  android:summary="This is the third paid setting that can be purchased"
                  android:inputType="phone"
                  android:dependency="paidSetting2"&gt;
              &lt;/EditTextPreference&gt;
          &lt;/PreferenceCategory&gt;
      &lt;/PreferenceScreen&gt;
  &lt;/PreferenceCategory&gt;
  &lt;/PreferenceScreen&gt;
  </code></pre>
  
  <hr>
  
  <p>Edit: I am still stuck on this problem and would appreciate any feedback on how to implement this.</p>