Search in sources :

Example 1 with IntentFilter

use of android.content.IntentFilter in project cw-omnibus by commonsguy.

the class RemoteViewsHostActivity method onResume.

@Override
public void onResume() {
    super.onResume();
    IntentFilter pluginFilter = new IntentFilter();
    pluginFilter.addAction(ACTION_REGISTER_PLUGIN);
    pluginFilter.addAction(ACTION_DELIVER_CONTENT);
    registerReceiver(plugin, pluginFilter, PERM_ACT_AS_PLUGIN, null);
    if (pluginCN == null) {
        sendBroadcast(new Intent(ACTION_CALL_FOR_PLUGINS));
    }
}
Also used : IntentFilter(android.content.IntentFilter) Intent(android.content.Intent)

Example 2 with IntentFilter

use of android.content.IntentFilter in project PlayerHater by chrisrhoden.

the class BroadcastReceiver method register.

public static void register(Context context) {
    BroadcastReceiver receiver = new BroadcastReceiver();
    IntentFilter filter = new IntentFilter();
    filter.addAction(Intent.ACTION_HEADSET_PLUG);
    filter.addAction(AudioManager.ACTION_AUDIO_BECOMING_NOISY);
    filter.addAction(Intent.ACTION_MEDIA_BUTTON);
    filter.setPriority(10000);
    context.registerReceiver(receiver, filter);
    sInstance = receiver;
}
Also used : IntentFilter(android.content.IntentFilter)

Example 3 with IntentFilter

use of android.content.IntentFilter in project cw-omnibus by commonsguy.

the class EventLogFragment method onStart.

@Override
public void onStart() {
    super.onStart();
    IntentFilter filter = new IntentFilter(ACTION_EVENT);
    LocalBroadcastManager.getInstance(getActivity()).registerReceiver(onEvent, filter);
}
Also used : IntentFilter(android.content.IntentFilter)

Example 4 with IntentFilter

use of android.content.IntentFilter in project cw-omnibus by commonsguy.

the class BatteryFragment method onStart.

@Override
public void onStart() {
    super.onStart();
    IntentFilter f = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
    getActivity().registerReceiver(onBattery, f);
}
Also used : IntentFilter(android.content.IntentFilter)

Example 5 with IntentFilter

use of android.content.IntentFilter in project qksms by moezbhatti.

the class Transaction method sendMMS.

private void sendMMS(final byte[] bytesToSend) {
    revokeWifi(true);
    // enable mms connection to mobile data
    mConnMgr = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
    int result = beginMmsConnectivity();
    if (LOCAL_LOGV)
        Log.v(TAG, "result of connectivity: " + result + " ");
    if (result != 0) {
        // if mms feature is not already running (most likely isn't...) then register a receiver and wait for it to be active
        IntentFilter filter = new IntentFilter();
        filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION);
        final BroadcastReceiver receiver = new BroadcastReceiver() {

            @Override
            public void onReceive(Context context1, Intent intent) {
                String action = intent.getAction();
                if (!action.equals(ConnectivityManager.CONNECTIVITY_ACTION)) {
                    return;
                }
                @SuppressWarnings("deprecation") NetworkInfo mNetworkInfo = intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO);
                if ((mNetworkInfo == null) || (mNetworkInfo.getType() != ConnectivityManager.TYPE_MOBILE)) {
                    return;
                }
                if (!mNetworkInfo.isConnected()) {
                    return;
                } else {
                    // ready to send the message now
                    if (LOCAL_LOGV)
                        Log.v(TAG, "sending through broadcast receiver");
                    alreadySending = true;
                    sendData(bytesToSend);
                    context.unregisterReceiver(this);
                }
            }
        };
        context.registerReceiver(receiver, filter);
        try {
            Looper.prepare();
        } catch (Exception e) {
        // Already on UI thread probably
        }
        // try sending after 3 seconds anyways if for some reason the receiver doesn't work
        new Handler().postDelayed(new Runnable() {

            @Override
            public void run() {
                if (!alreadySending) {
                    try {
                        if (LOCAL_LOGV)
                            Log.v(TAG, "sending through handler");
                        context.unregisterReceiver(receiver);
                    } catch (Exception e) {
                    }
                    sendData(bytesToSend);
                }
            }
        }, 7000);
    } else {
        // mms connection already active, so send the message
        if (LOCAL_LOGV)
            Log.v(TAG, "sending right away, already ready");
        sendData(bytesToSend);
    }
}
Also used : Context(android.content.Context) IntentFilter(android.content.IntentFilter) NetworkInfo(android.net.NetworkInfo) Handler(android.os.Handler) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) BroadcastReceiver(android.content.BroadcastReceiver) MmsException(com.google.android.mms.MmsException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

IntentFilter (android.content.IntentFilter)2652 Intent (android.content.Intent)881 Context (android.content.Context)503 BroadcastReceiver (android.content.BroadcastReceiver)438 PendingIntent (android.app.PendingIntent)224 View (android.view.View)115 TextView (android.widget.TextView)101 Handler (android.os.Handler)99 ComponentName (android.content.ComponentName)89 RemoteException (android.os.RemoteException)81 ArrayList (java.util.ArrayList)81 PowerManager (android.os.PowerManager)75 Test (org.junit.Test)75 SuppressLint (android.annotation.SuppressLint)66 Uri (android.net.Uri)64 LocalBroadcastManager (android.support.v4.content.LocalBroadcastManager)56 SharedPreferences (android.content.SharedPreferences)55 ResolveInfo (android.content.pm.ResolveInfo)55 ImageView (android.widget.ImageView)50 File (java.io.File)47