0

When I'm trying to pass data to another activity it for some reason gets lost. My sending activity looke like:

protected OnItemClickListener onArtistItemClick = new OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> adapter, View arg1, int cursor, long arg3) {
            Intent artistCardIntent = new Intent(getBaseContext(),  ArtistCardActivity.class);
            Artist artist = (Artist) adapter.getItemAtPosition(cursor);
            artistCardIntent.putExtra("artist_id", artist.getId());
            artistCardIntent.putExtra("tt", "tt");
            startActivity(artistCardIntent);
        };
    };

And while debugging I can see that artistCardIntent gets populated, however in the receiving activity Intent i doesn't contain any extra inforamation:

public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.artist_card);
            Intent i = getIntent();

What am I doing wrong?

PS both activities extends FragmentActivity. Thanks.

user1384991
  • 2,559
  • 3
  • 17
  • 20
  • did you checked getIntent().hasExtra("artist_id"); whether its true or false in secod activity – Akram May 23 '12 at 13:36

3 Answers3

1

To receive the data use getextras() method. Find the following code. i think it helps you

       Intent i = getIntent();
       Bundle b=i.getExtras();
       if(b!=null)
      {
      String artist= ("artist_id");
          }
code_finder
  • 1,370
  • 2
  • 21
  • 39
  • yeah, it seems getExtras makes some adjustments to it's Intent object. In fact Phobos was talking about it. Thanks – user1384991 May 23 '12 at 13:42
0

convert those values to string and try it , It will work

startActivity(new Intent(Home.this,galmenu.class).putExtra("page","home"));

     Intent myIntent = getIntent(); 
     test=myIntent.getExtras().getString("page");

it is working perfectly

Thiru VT
  • 831
  • 2
  • 8
  • 24
0

I don't see that you are getting the extra information.

Check out this answer How do I get extra data from intent on Android?

Community
  • 1
  • 1
Phobos
  • 9,447
  • 3
  • 25
  • 30