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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:41:42+00:00 2026-05-30T12:41:42+00:00

Situation is this: Activity A calls getLocation() method from Class B. Class B handles

  • 0

Situation is this:

  1. Activity A calls getLocation() method from Class B.

Class B handles obtaining GPS locations.

2 Activity A should finish once Class B has finished retrieving GPS
location.

Activity A calls something like:

B.getLocation()
this.finish()

i.e. gets the location using method from B and then finishes itself. In reality, A closes before B has a chance to get the location.

How do I structure this correctly so that A waits till B has finished?

  • 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-30T12:41:44+00:00Added an answer on May 30, 2026 at 12:41 pm

    The design here is lacking. In fact, you can’t just call one Activity‘s method for the other one, since only one Activity can be in foreground at the moment. Your activities should communicate using Intents. Here’s how it should work:

    1. Activity A starts Activity B using an Intent
    2. Activity B gets location and returns it to Activity A, using the setResult() method
    3. Activity A reads the result from Activity B in its onActivityResult() method
    4. Activity A finishes

    This feels like a better implementation. Actually, if Activity B does just get location, you can simple implement it as a Service and bind it to Activity A. Hope this helps.

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

Sidebar

Related Questions

I have this situation where i have to start an activity from my mainActivity.
In this situation I am trying to perform a data import from an XML
This situation arises from someone wanting to create their own pages in their web
I've something along this lines: public class Something { private IDictionary<object,Activity> fCases; public IDictionary<object,Activity>
I have a situation like this I'm using a single activity but with different
I ran across this situation this afternoon, so I thought I'd ask what you
In this situation I have two models, Comment and Score. The relationship is defined
The situation is this: You have a Hibernate context with an object graph that
Look at this situation: www.websitea.com displays an img tag with a src attribute of
The Situation (Ignore this it is boring): I have reports that I created using

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.