start Activity With Object For Result - Android Activity

Android examples for Activity:Activity Start

Description

start Activity With Object For Result

Demo Code


//package com.java2s;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

import java.io.Serializable;

public class Main {
    public static void startActivityWithObjectForResult(Context context,
            Class<?> toClass, String key, Serializable obj, int requestCode) {
        Intent intent = new Intent();
        intent.setClass(context, toClass);
        Bundle bundle = new Bundle();
        bundle.putSerializable(key, obj);
        intent.putExtras(bundle);/* w ww.  ja v  a2 s .  c  o m*/
        //        int id =((IdObj)bundle.getSerializable("  ")).getId();
        ((Activity) context).startActivityForResult(intent, requestCode);
    }
}

Related Tutorials