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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T22:15:11+00:00 2026-05-25T22:15:11+00:00

I know the listeners are supposed to make life easier, especially in a multi-tasking

  • 0

I know the listeners are supposed to make life easier, especially in a multi-tasking environment like android, but sometimes (to me) it just makes things harder.

Right now I have an ExpandableList activity which presents a list of events, and I want the user to select the group & child of interest and select a notification sound that will play when that event happens. So the list is set up and I have a setOnChildClickListener set up which runs my SetRingtone method:

protected void SetRingtone(int groupPosition, int childPosition) {
  Intent intent = new Intent( RingtoneManager.ACTION_RINGTONE_PICKER);
  intent.putExtra( RingtoneManager.EXTRA_RINGTONE_TYPE, 
    RingtoneManager.TYPE_ALL);
  intent.putExtra( RingtoneManager.EXTRA_RINGTONE_TITLE, 
    "Select Tone");
  startActivityForResult( intent, PICK_NOTIFICATION_SOUND); 
}

So that method has access to the selected group and child positions. The problem is that to get the ringtone selected from the ringtone selector, you have to set up another lister, onActivityResult:

protected void onActivityResult(int requestCode, 
    int resultCode, Intent data) {
  if (resultCode == RESULT_OK) {
    Uri uri = 
     data.getParcelableExtra(RingtoneManager.EXTRA_RINGTONE_PICKED_URI);
    if (uri != null) {
      String ringTonePath = uri.toString();
      ExpandableListView variableView = 
      (ExpandableListView)findViewById(android.R.id.list);
      int p = variableView.getSelectedItemPosition();
      Log.d("phca", "The selected item number was: " + 
      p + "; The sound selected is: " + uri );
    }
  }
}

And now I don’t have access to the selected group and child. As you can see, I tried to get the position from the getSelectedItemPosition, but it always returns -1 here.

I know I am probably making this harder than it really is.

  • 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-25T22:15:12+00:00Added an answer on May 25, 2026 at 10:15 pm

    You could just store the group and child in instance variables before the call to startActivityForResult and then use these instance variables in onActivityResult.

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

Sidebar

Related Questions

I know that there are listeners in JavaFX, and i'm sure Java. But I'm
I just got started with Android and I was wondering how to use listeners
I would like to know how a listener should let the parent thread know
Know of an OCAML/CAML IDE? Especially one that runs on Linux?
Know this might be rather basic, but I been trying to figure out how
I know that event listeners and references to an object will prevent the garbage
I am using NSNotificationCenter object. I need to know all the listeners and the
There are Filters and Listeners functionality in Servlet. I want to know exact difference
Is it possible to attach multiple onClick listeners to buttons in android? Example: btn1.setOnClickListener(listener1);
I know I may be asking for the moon here but I'm looking for

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.