set Activity Result - Android Activity

Android examples for Activity:Activity Status

Description

set Activity 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 setActivityResult(Context context, int requestCode,
            String key, Serializable obj) {
        Intent intent = getBundleIntent(getSingleObjectBundle(key, obj));
        ((Activity) context).setResult(requestCode, intent);
    }/*from w ww . ja v a  2 s  . com*/

    public static Intent getBundleIntent(Bundle bundle) {
        Intent intent = new Intent();
        intent.putExtras(bundle);
        return intent;
    }

    public static Bundle getSingleObjectBundle(String key, Serializable obj) {
        Bundle bundle = new Bundle();
        bundle.putSerializable(key, obj);
        return bundle;
    }
}

Related Tutorials