set Activity Result - Android android.app

Android examples for android.app:Activity Property

Description

set Activity Result

Demo Code

import java.io.Serializable;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

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 . j ava2s  . c  o  m*/

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

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

}

Related Tutorials