Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I think you've a main activity that shows first when your app is executed. You can put in <code>onCreate()</code> a very simple code to load the preference activity only if it's the first time you run the app. Like this:</p> <pre><code>import android.content.SharedPreferences; import android.app.Activity; import android.os.Bundle; public class ActivityMain extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // get shared preferences SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); // first time run? if (pref.getBoolean("firstTimeRun", true)) { // start the preferences activity startActivity(new Intent(getBaseContext(), ActivityEditPreferences.class)); //get the preferences editor SharedPreferences.Editor editor = pref.edit(); // avoid for next run editor.putBoolean("firstTimeRun", false); editor.commit(); } } } </code></pre> <p>The <code>ActivityEditPreferences</code> is the other activity that loads the default Android preference editor. Hope this can help you.</p> <p><strong>EDIT:</strong> For completeness I show you also the activity that manages the preferences:</p> <pre><code>import android.app.Activity; import android.content.SharedPreferences; import android.os.Bundle; import android.preference.Preference; import android.preference.PreferenceActivity; import android.preference.Preference.OnPreferenceClickListener; import android.widget.Toast; public class ActivityEditPreferences extends PreferenceActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); ... </code></pre> <p>You can get a complete example here: <a href="http://www.kaloer.com/android-preferences" rel="nofollow">http://www.kaloer.com/android-preferences</a></p> <p>And don't forget to look at the official reference: <a href="http://developer.android.com/reference/android/preference/PreferenceActivity.html" rel="nofollow">http://developer.android.com/reference/android/preference/PreferenceActivity.html</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload