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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:05:29+00:00 2026-05-15T14:05:29+00:00

The following is my code for SettingsActivity.java. The main activity starts this activity by

  • 0

The following is my code for SettingsActivity.java. The main activity starts this activity by calling onScreenSettings(this)

public class SettingsActivity extends ListActivity{

static String[] main_settings = {"mode",
                            "timeout"
};
static String[] mode = { "Audio",
                  "Video",
                  "Audio/Video"
};
static String[] timeout = {
                        "1 min",
                        "5 min",
                        "10 min"
};
static String result;
static String[] display;

boolean settings_selected = false;
static String TAG = "****ALIST****";


public static void onScreenSettings(Activity c){

    display = main_settings;
    Log.d(TAG,"inside onScreenSettings");
    Intent intent = new Intent(c.getApplication(),SettingsActivity.class);
    try{
        c.startActivityForResult(intent,1);
        Log.d(TAG,"after starting activity in onScreenSettings");
    }catch(Exception e){

    }
}





@Override
public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    Log.d(TAG,"inside onCreate-before setting listview");
    setListAdapter(new ArrayAdapter<String>(this,
               android.R.layout.simple_list_item_1, display));
        getListView().setTextFilterEnabled(true);
        Log.d(TAG,"inside oncreate-after setting listview");

}
public void onListItemClick(ListView l, View v, int position, long id){
     result = (String) l.getItemAtPosition(position);
     if(!settings_selected){
         if(result.equals("mode")){
        display = mode;         
         }
         else if(result.equals("timeout")){
        display = timeout;              
         }
         settings_selected = true;
         Log.d(TAG,"if !setting_selected");

     }
     else{/*accepting the sub options*/
         display = main_settings;//next the main settings must be displayed
         if(result.equals("Audio")){

         }
         else if(result.equals("Video")){
             Log.d(AndroidRecorder.TAG,"inside sub option Video");
         }
         else if(result.equals("Audio/Video")){

         }
         settings_selected = false;
         Log.d(TAG,"if setting_selected");
     }
     Intent intent = new Intent(this.getApplication(),SettingsActivity.class);
     try{
        startActivityForResult(intent,1);
        Log.d(TAG,"after starting activity in ListItemClick");
    }
    catch(Exception e){

    }

}
public void onActivityResult(int requestCode, int resultCode,Intent data) {
    //nothing to do with the intent here
    Log.d(TAG,"inside onActivityResult");
    setResult(RESULT_OK, data);
    finish();
    Log.d(TAG,"inside onActivityResult-after finish()");
}
/*public void onBackPressed(){
    Log.d(TAG,"inside onBackPressed");
    finish();
    Log.d(TAG,"inside onBackPressed-after finish()");

}*/

}//end of ListActivity

Problem is control is not entering the else /*accepting the sub options*/ and I can’t figure out why. As a result, the mode or timeout list is getting displayed again and again and the main_settings is not displayed.
Please help.

  • 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-15T14:05:30+00:00Added an answer on May 15, 2026 at 2:05 pm

    When you call startActivityForResult in onListItemClick you get a whole new instance of the SettingsActivity. Does logcat show “inside oncreate” right after it shows “if !setting_selected”?

    If it does and you don’t want to go through major refactoring, you can stuff the value of setting_selected into an extra on the intent and pull it out in onCreate.

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

Sidebar

Ask A Question

Stats

  • Questions 462k
  • Answers 462k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I think what you need to do, is have a… May 16, 2026 at 12:16 am
  • Editorial Team
    Editorial Team added an answer You need to: tell the browser what encoding you wish… May 16, 2026 at 12:16 am
  • Editorial Team
    Editorial Team added an answer Check that all of the usernames in potovanja exist in… May 16, 2026 at 12:16 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.