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 3317270
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:34:05+00:00 2026-05-17T22:34:05+00:00

i created application in that it will call preference from main activity based on

  • 0

i created application in that it will call preference from main activity based on menu option
it is done using Explicit intent but it not working . when clicking the menu item
calling activity

public boolean onCreateOptionsMenu(Menu menu)
{
    super.onCreateOptionsMenu(menu);

    menu.add(0,  Menu.FIRST+1, Menu.NONE, "Refresh");
    menu.add(0, Menu.FIRST+3, Menu.NONE, "Set Preferences");

    return true;
}

public boolean onOptionItemSelected(MenuItem item)
{
    switch(item.getItemId()) 
    {
        case Menu.FIRST+1:
            Intent intent =new Intent(this,userpreferences.class);
            startActivityForResult(intent,this.USER_PREFERENCES);
            return true;

        case Menu.FIRST+3:

            return true;    
    }

    return false;
}

preference xml

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
    <CheckBoxPreference
        android:key="AUTO_UPDATE" android:title="update automatically"
        android:summary="update automatically" android:defaultValue="true" />
    <ListPreference android:key="MINIMUM_MARK" android:title="minimum mark"     
        android:summary="enter the minimum mark of the student" 
        android:defaultValue="30" android:entries = "@array/minimumMarks"   
        android:entryValues="@array/minimum_mark_values" 
        android:dialogTitle="Check the minimum mark required" />
</PreferenceScreen>

Preference activity

package com.xml.parse;

import android.os.Bundle;
import android.preference.PreferenceActivity;

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

some body plz tell me to do better or correct way

Regards,

Kariyachan

  • 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-05-17T22:34:05+00:00Added an answer on May 17, 2026 at 10:34 pm

    Do not use startActivityForResult() — startActivity() is fine. Here is a sample project showing the use of an options menu item to open a PreferenceActivity.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to find/create an application that will create employee web usage reports from
The MFC application that i created is dialog based. Just one dialog thats all.
I'm trying to create an application that will let me execute a method specified
I'm working on a web application. A user will create an email message that
I have created an application that writes some data to the root folder of
I have created an application that runs in the taskbar. When a user clicks
I've created a web application that I've hosted with IIS 7 on a Windows
I have created a console application that calls a method on a webservice. I
I have an application that has created a number of custom event log sources
I have a C application that I've created in VS2008. I am creating a

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.