Simple question about passing data to activity

Put your problem here if it does not fit any of the other categories.

Simple question about passing data to activity

Postby szimek » Wed Dec 19, 2007 7:26 pm

Hi!

I'd like to extend "Contact-List Caller" sample to add a list of available phone types/numbers for selected person. So I need another activity and pass selected person ID to it.

The example there uses
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. intent.setData(Foos.CONTENT_URI.addId(fooID));
Parsed in 0.029 seconds, using GeSHi 1.0.8.4

while the "Passing Data to Activities" tutorial on this forum uses Bundle to pass data.

What is the difference? How to get data in an activity when it's passed using intent.setData?

BTW. Is the id parameter in onListItemClick by any chance ID of the selected element in a database?

Thanks in advance!
szimek
Freshman
Freshman
 
Posts: 6
Joined: Wed Dec 19, 2007 3:38 pm

Top

Postby szimek » Wed Dec 19, 2007 9:14 pm

Got it:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. long personId = getIntent().getData().getPathLeafId();
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


Few more questions:
- is it ok to send ID like this or should I use Bundle instead?
- what's the difference between position and id parameters in onListItemClick?
- how to get phone type name? I can do Phones.TYPE, but I get integer instead of string like "Mobile", "Work" etc. Is there an easy way to fetch default name of each type or do I have to write it myself? Now I've got this:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. String[] columns = new String[] { Phones.TYPE, Phones.NUMBER_KEY };
  2.  
  3. int[] phones = new int[] {R.id.phone_type, R.id.phone_number};
  4.  
  5.  
  6.  
  7. mAdapter = new SimpleCursorAdapter(this, R.layout.phones_list, c, columns,
  8.  
  9.                 phones);
  10.  
  11. setListAdapter(mAdapter);
Parsed in 0.034 seconds, using GeSHi 1.0.8.4

- I've changed phone numbers of few contacts, but when I run my app, I still get old phone numbers - what's wrong?

Thanks in advance
szimek
Freshman
Freshman
 
Posts: 6
Joined: Wed Dec 19, 2007 3:38 pm

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 19 guests