Android

Android: Debugging Arts of the Ninja Masters

Friday, September 10th, 2010

httpvh://www.youtube.com/watch?v=Dgnx0E7m1GQ

Via: http://code.google.com/events/io/2009/sessions/DebuggingArtsNinjaMasters.html

Android: Passing data to an activity

Thursday, June 18th, 2009

Sometimes when you’re launching another activity you want to pass some data to it. This is done via a bundle, here’s sample code:

In launching activity(MyActivity1):

Intent i = new Intent( MyActivity1.this, MyActivity2.class ) ;
i.putExtra(”someIntData”, 200) ;
i.putExtra(”someStringData”, “This is a string”) ;
startActivity(i) ;

In launched activity( MyActivity2):

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle extras = getIntent().getExtras() ;
    if( extras != null ){
        int intValue = extras.getInt( “someIntValue” ) ;
        String stringValue = extras.getString( “someStringValue” ) ;
    }
}

Using the same process you can also pass arrays and array lists. For a full list of what can be passed refer to Android SDK documentation on Bundles here.