send Intent Broad Cast - Android Intent

Android examples for Intent:Broadcast

Description

send Intent Broad Cast

Demo Code


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

public class Main {
    public static void sendBroadCast(Context context, String action,
            String key, String value) {
        Intent intent = new Intent();
        intent.setAction(action);//from  www . j ava2  s.  com
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        intent.putExtra(key, value);
        context.sendBroadcast(intent);
    }

    public static void sendBroadCast(Context context, String action,
            String key, int value) {
        Intent intent = new Intent();
        intent.setAction(action);
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        intent.putExtra(key, value);
        context.sendBroadcast(intent);
    }
}

Related Tutorials