send Common Intent Broad Cast - Android Intent

Android examples for Intent:Broadcast

Description

send Common Intent Broad Cast

Demo Code


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

public class Main{
    public static void sendCommonBroadCast(Context context, String content) {
        Intent intent = new Intent();
        intent.setAction(ConstantsValue.COMMON_ACTION);
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        intent.putExtra(ConstantsValue.COMMON_ACTION, content);
        context.sendBroadcast(intent);/*  w w  w .  ja va  2  s  .c o m*/
    }
    public static void sendBroadCast(Context context, String action,
            String key, String value) {
        Intent intent = new Intent();
        intent.setAction(action);
        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