build Intent for action and data - Android Intent

Android examples for Intent:Intent Bundle

Description

build Intent for action and data

Demo Code


//package com.java2s;
import android.content.Context;
import android.content.Intent;

public class Main {
    public static Intent buildIntent(final Context context, String action,
            String data) {/*from w w  w  .j  a  v a 2  s  . c  om*/
        Intent intent = new Intent(action);
        intent.putExtra("what", data);
        intent.setPackage(context.getPackageName());
        return intent;
    }
}

Related Tutorials