Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Help me with switching between two activities

Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I have a google maps application in android. This application has two activities, Activity 1 is used to display map of user's current location, and permits user to input some text to search. Activity 2 is used to display the results on the map.
In activity 1, I have some code to call Activity 2 as following:

public void onClick(View v) {
// get inputed information
requiredValue = textField.getText().toString();
// initiate new Activity
Intent intent = new Intent(Intent.ACTION_VIEW);
// bun is a tool to pass parameters to other Activity
Bundle bun = new Bundle();

double[] coordinate = { latitude, longtitude };
bun.putDoubleArray("coordinate", coordinate);
bun.putString("requiredShopName", requiredValue);

intent.setClass(this, SaleInformation.class);


After clicking Search button, everything works well, the results is displayed on map. That means that Acvitiy 2 has done. But when i search again, after clicking Search button, nothing happens. I guess that both Activity 1 and 2 has died.
Please tell me how to resolve this problem?
Ranch Hand
Posts: 56
Android Mac Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
After starting Activity 2 you finish() Activity 1, so Activity 1 is gone.
If you can't handle a new search in Activity 2 don't use finish() so you can return to Activity 1 by pressing "back" or execute finish() in Activity 2.
Not so fast naughty spawn! I want you to know about
We need your help - Coderanch server fundraiser
    Bookmark Topic Watch Topic
  • New Topic