Skip to content Skip to sidebar Skip to footer

How To Use 1 Intent To Transport Between Activities?

I'm using Xamarin to develop android programs. My app has many different activities which they pass data to each other by using for example this code: Intent myIntent = new Intent(

Solution 1:

You can use Application class for accessing same object across many activities.

publicclassTestApplicationextendsApplication {

    publicTempClass tempClass;

    publicTestApplication () {
        // TODO Auto-generated constructor stub
    }

    @OverridepublicvoidonCreate() { 
        // TODO Auto-generated method stubsuper.onCreate();
    }

    publicTempClassgetTempClass() {
        return tempClass;
    }

    publicvoidsetTempClass(TempClass tempClass) {
        this.tempClass  = tempClass;
    }
}

Now in your Activity:

//after setContentView
testAppObj = (TestApplication) getApplication();
testAppObj.setTempClass(myTempClassObj);

//retrieve as:TempClassobj= testAppObj.getTempClass();

Hope this helps.

P.S: You must register your Application class in your manifest file just like you register your activities:

<applicationandroid:name="com.pkg.test.TestApplication " />

Post a Comment for "How To Use 1 Intent To Transport Between Activities?"