Send broadcast Intent - Android Intent

Android examples for Intent:Map

Description

Send broadcast Intent

Demo Code


//package com.java2s;

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

import android.text.TextUtils;

public class Main {
    public static void broadcast(Context context, String action,
            String packageName, String className) {
        try {/*from w ww.j a  va 2  s.  c  o m*/
            Intent intent = new Intent(action);
            if (!TextUtils.isEmpty(packageName)
                    && !TextUtils.isEmpty(className)) {
                intent.setClassName(packageName, className);
            }
            context.sendBroadcast(intent);
        } catch (Throwable e) {
            throw new IllegalArgumentException("illegal argument exception");
        }
    }
}

Related Tutorials