platypus
platypus

Reputation: 706

Pass realtime information between activities

I have two activities in my Android project:

  1. Google Map Activity
  2. List Activity

I'm trying to pass an item's location information to GMAP Activity and add it as an overlay to the map. I know i have to use putExtra and getExtra but I want to add that location to the Google Map and show it to user when user taps on a List Activity item. How can i do that?

Upvotes: 0

Views: 111

Answers (1)

Shankar Agarwal
Shankar Agarwal

Reputation: 34765

You can use ListView's setOnItemClickListener, and start an new GMAP in your implementation of this method. Following is sample code:

listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
    public void onItemClick(AdapterView parent, View v, int position, long id){
        // Start your Activity according to the item just clicked.
        //also put extras.
        Intent newIntent = new Intent(ListActivity.this, GMAPActivity.class);
        newIntent.putExtra(key,value);
        startActivity(newIntent);
    }
};

Upvotes: 1

Related Questions