List of usage examples for android.content IntentFilter addAction
public final void addAction(String action)
From source file:Main.java
public static void registerReceiver(Context context, BroadcastReceiver receiver, String action) { IntentFilter filter = new IntentFilter(); filter.addAction(action); context.registerReceiver(receiver, filter); }
From source file:Main.java
public static void registBroadcase(Activity activity, BroadcastReceiver receiver, String name) { LocalBroadcastManager broadcastManager = LocalBroadcastManager.getInstance(activity); IntentFilter filter = new IntentFilter(); filter.addAction(name); broadcastManager.registerReceiver(receiver, filter); }
From source file:Main.java
public static int getBatteryLevel(Context context) { IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_BATTERY_CHANGED); Intent intent = context.registerReceiver(null, filter); if (intent == null) { return -1; }//from w ww . j av a2 s . c om return intent.getIntExtra(BatteryManager.EXTRA_LEVEL, 0); }
From source file:Main.java
public static void registerBroadcast(Context context, String action, BroadcastReceiver broadcastReceiver) { if (context == null || TextUtils.isEmpty(action) || broadcastReceiver == null) { return;/*from ww w. j a v a 2s . c om*/ } IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(action); context.registerReceiver(broadcastReceiver, intentFilter); }
From source file:Main.java
/** * register bluetooth receiver//from w w w.j ava2 s.co m * * @param receiver bluetooth broadcast receiver * @param activity activity */ public static void registerBluetoothReceiver(BroadcastReceiver receiver, Activity activity) { if (null == receiver || null == activity) { return; } IntentFilter intentFilter = new IntentFilter(); //start discovery intentFilter.addAction(BluetoothAdapter.ACTION_DISCOVERY_STARTED); //finish discovery intentFilter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED); //bluetooth status change intentFilter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); //found device intentFilter.addAction(BluetoothDevice.ACTION_FOUND); //bond status change intentFilter.addAction(BluetoothDevice.ACTION_BOND_STATE_CHANGED); //pairing device intentFilter.addAction("android.bluetooth.device.action.PAIRING_REQUEST"); activity.registerReceiver(receiver, intentFilter); }
From source file:com.finchuk.clock2.util.LocalBroadcastHelper.java
/** Registers a BroadcastReceiver that filters intents by the actions specified */ public static void registerReceiver(Context context, BroadcastReceiver receiver, String... actions) { IntentFilter filter = new IntentFilter(); for (String action : actions) filter.addAction(action); LocalBroadcastManager.getInstance(context).registerReceiver(receiver, filter); }
From source file:com.github.luluvise.droid_utils.lib.network.NetworkReceiver.java
/** * Return the {@link IntentFilter} to subscribe to network connectivity * changes/*ww w . ja v a 2 s . co m*/ */ public static IntentFilter getFilter() { final IntentFilter filter = new IntentFilter(); filter.addAction(NetworkBroadcastReceiver.ACTION_NETWORK_ACTIVE); filter.addAction(NetworkBroadcastReceiver.ACTION_NETWORK_GONE); return filter; }
From source file:com.allfirebasedemo.storagepackage.MyDownloadService.java
public static IntentFilter getIntentFilter() { IntentFilter filter = new IntentFilter(); filter.addAction(DOWNLOAD_COMPLETED); filter.addAction(DOWNLOAD_ERROR);/*from www. j a va 2 s . c o m*/ return filter; }
From source file:br.com.maracujas.classicrockwallpapersfinal.MyDownloadService.java
public static IntentFilter getIntentFilter() { IntentFilter filter = new IntentFilter(); filter.addAction(ACTION_COMPLETED); filter.addAction(ACTION_ERROR);/* www . j av a 2 s. co m*/ return filter; }
From source file:Main.java
private static IntentFilter createIntentFilter(String[] intentFilters) { IntentFilter filter = new IntentFilter(intentFilters[0]); for (int i = 0; i < intentFilters.length; i++) { if (i == 0) { continue; }/* w w w . j a v a 2 s .co m*/ filter.addAction(intentFilters[i]); } return filter; }