views:

216

answers:

1

hi

I want to get the hashtable object from non activity class to activity class an android

please reply to me

thanks

A: 

you can pass it through the intent object using extras. Something like this

after creating the intent in your non-activity class set the value using

objIntent.putExtra("keyName", "somevalue");

In the activity class access it like this

Bundle extras = getIntent().getExtras();
if(extras !=null)
{
String value = extras.getString("keyName");
}
zapping
thanks, how to send hashtable object to activtiy class
saravanan
i.eclass CityList extends Activity { DBConnection server = new DBConnection(); server.getDataValues(); try { Bundle extras = getIntent().getExtras(); ArrayList<String> list = extras.getStringArrayList("city"); System.out.println(list.get(0)); System.out.println(list.get(1)); } catch(Exception e) { System.out.println(e.toString()); }}class ServerConnection {....Intent intent = new Intent(this, CityList.class);ArrayList<String> list = new ArrayList<String>(); list.add("city_1"); list.add("city_2"); intent.putStringArrayListExtra("city", list);..}
saravanan
but igot nullpointer exception
saravanan
can you please edit your original post and add this as code. its not readable.
zapping