jump To Activity For Result - Android Activity

Android examples for Activity:Activity Jump

Description

jump To Activity For Result

Demo Code


//package com.java2s;
import android.app.Activity;

import android.content.Context;
import android.content.Intent;

public class Main {
    public static void jumpToActivityForResult(Context context,
            Class<? extends Activity> targetClass, int resultId,
            String... datas) {//from  w ww.j a  v a  2  s  . c o m
        Intent datatIntent = new Intent(context, targetClass);
        if (datas != null) {
            for (int i = 0; i < datas.length; ++i) {
                datatIntent.putExtra("data" + i, datas[i]);
            }
        }

        ((Activity) context).startActivityForResult(datatIntent, resultId);
    }

    public static void jumpToActivityForResult(Context context,
            Class<? extends Activity> targetClass, int resultId) {
        Intent datatIntent = new Intent(context, targetClass);
        ((Activity) context).startActivityForResult(datatIntent, resultId);
    }
}

Related Tutorials