Java Code Examples for android.app.Application#registerReceiver()
The following examples show how to use
android.app.Application#registerReceiver() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MissService.java From UPMiss with GNU General Public License v3.0 | 6 votes |
@Override public void onCreate() { super.onCreate(); Model.log(TAG, "onCreate"); Application application = getApplication(); mReceiver = new MissServiceBroadcastReceiver(); try { IntentFilter filter = new IntentFilter(); filter.addAction(ACTION_MISS_WIDGET_REFRESH); application.registerReceiver(mReceiver, filter); } catch (Exception e) { e.printStackTrace(); } // Register Alarm addAlarm(getApplication()); }
Example 2
Source File: XApplication.java From XPrivacy with GNU General Public License v3.0 | 6 votes |
@Override protected void after(XParam param) throws Throwable { switch (mMethod) { case onCreate: // Install receiver for package management if (PrivacyManager.isApplication(Process.myUid()) && !mReceiverInstalled) try { Application app = (Application) param.thisObject; if (app != null) { mReceiverInstalled = true; Util.log(this, Log.INFO, "Installing receiver uid=" + Process.myUid()); app.registerReceiver(new Receiver(app), new IntentFilter(ACTION_MANAGE_PACKAGE), PERMISSION_MANAGE_PACKAGES, null); } } catch (SecurityException ignored) { } catch (Throwable ex) { Util.bug(this, ex); } break; } }
Example 3
Source File: EasyBLE.java From easyble-x with Apache License 2.0 | 5 votes |
public synchronized void initialize(@NonNull Application application) { if (isInitialized()) { return; } Inspector.requireNonNull(application, "application can't be"); this.application = application; //检查是否支持BLE if (!application.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) { return; } //获取蓝牙配置器 BluetoothManager bluetoothManager = (BluetoothManager) application.getSystemService(Context.BLUETOOTH_SERVICE); if (bluetoothManager == null || bluetoothManager.getAdapter() == null) { return; } bluetoothAdapter = bluetoothManager.getAdapter(); //注册蓝牙开关状态广播接收者 if (broadcastReceiver == null) { broadcastReceiver = new InnerBroadcastReceiver(); IntentFilter filter = new IntentFilter(); filter.addAction(BluetoothAdapter.ACTION_STATE_CHANGED); filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_STARTED); filter.addAction(BluetoothAdapter.ACTION_DISCOVERY_FINISHED); filter.addAction(BluetoothDevice.ACTION_FOUND); application.registerReceiver(broadcastReceiver, filter); } isInitialized = true; }
Example 4
Source File: ModuleContext.java From ZjDroid with Apache License 2.0 | 5 votes |
@Override public void afterHookedMethod(HookParam param) { if (!HAS_REGISTER_LISENER) { fristApplication = (Application) param.thisObject; BroadcastReceiver broadcastReceiver = new CommandBroadcastReceiver(); fristApplication.registerReceiver(broadcastReceiver, new IntentFilter(CommandBroadcastReceiver.INTENT_ACTION)); HAS_REGISTER_LISENER = true; } }
Example 5
Source File: ScannerViewModel.java From mcumgr-android with Apache License 2.0 | 5 votes |
/** * Register for required broadcast receivers. */ private void registerBroadcastReceivers(@NonNull final Application application) { application.registerReceiver(mBluetoothStateBroadcastReceiver, new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED)); if (Utils.isMarshmallowOrAbove()) { application.registerReceiver(mLocationProviderChangedReceiver, new IntentFilter(LocationManager.MODE_CHANGED_ACTION)); } }
Example 6
Source File: LiveEventBusCore.java From LiveEventBus with Apache License 2.0 | 5 votes |
void registerReceiver() { if (isRegisterReceiver) { return; } Application application = AppUtils.getApp(); if (application != null) { IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(IpcConst.ACTION); application.registerReceiver(receiver, intentFilter); isRegisterReceiver = true; } }
Example 7
Source File: LiveEventBusCore.java From LiveEventBus with Apache License 2.0 | 5 votes |
void registerReceiver() { if (isRegisterReceiver) { return; } Application application = AppUtils.getApp(); if (application != null) { IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(IpcConst.ACTION); application.registerReceiver(receiver, intentFilter); isRegisterReceiver = true; } }
Example 8
Source File: ModuleContext.java From zjdroid with Apache License 2.0 | 5 votes |
@Override public void afterHookedMethod(HookParam param) { // TODO Auto-generated method stub if (!HAS_REGISTER_LISENER) { fristApplication = (Application) param.thisObject; IntentFilter filter = new IntentFilter(CommandBroadcastReceiver.INTENT_ACTION); fristApplication.registerReceiver(new CommandBroadcastReceiver(), filter); HAS_REGISTER_LISENER = true; } }
Example 9
Source File: Oncreatehook.java From AppTroy with Apache License 2.0 | 5 votes |
@Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { Log.d("cc", "after, register receiver"); if (!ModuleContext.HAS_REGISTER_LISENER) { Application firstApplication = (Application) param.thisObject; IntentFilter filter = new IntentFilter(CommandBroadcastReceiver.INTENT_ACTION); firstApplication.registerReceiver(new CommandBroadcastReceiver(), filter); ModuleContext.HAS_REGISTER_LISENER = true; ModuleContext.getInstance().setFirstApplication(firstApplication); Log.d("cc", "register over"); } }
Example 10
Source File: ScannerViewModel.java From Android-nRF-Blinky with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Register for required broadcast receivers. */ private void registerBroadcastReceivers(@NonNull final Application application) { application.registerReceiver(bluetoothStateBroadcastReceiver, new IntentFilter(BluetoothAdapter.ACTION_STATE_CHANGED)); if (Utils.isMarshmallowOrAbove()) { application.registerReceiver(locationProviderChangedReceiver, new IntentFilter(LocationManager.MODE_CHANGED_ACTION)); } }
Example 11
Source File: ModuleContext.java From HeyGirl with Apache License 2.0 | 5 votes |
@Override public void afterHookedMethod(HookParam param) { // TODO Auto-generated method stub if (!HAS_REGISTER_LISENER) { fristApplication = (Application) param.thisObject; IntentFilter filter = new IntentFilter(CommandBroadcastReceiver.INTENT_ACTION); fristApplication.registerReceiver(new CommandBroadcastReceiver(), filter); HAS_REGISTER_LISENER = true; } }
Example 12
Source File: ModuleContext.java From ZjDroid with Apache License 2.0 | 5 votes |
@Override public void afterHookedMethod(HookParam param) { // TODO Auto-generated method stub if (!HAS_REGISTER_LISENER) { fristApplication = (Application) param.thisObject; IntentFilter filter = new IntentFilter(CommandBroadcastReceiver.INTENT_ACTION); fristApplication.registerReceiver(new CommandBroadcastReceiver(), filter); HAS_REGISTER_LISENER = true; } }
Example 13
Source File: ExoHelper.java From buck with Apache License 2.0 | 5 votes |
/** * Enable hotswapping on an application instance. This call is not necessary if using {@link * ExopackageApplication}. If enabling manually, make sure the app is set up to support the * "modules" exopackage mode, and the initial call to {@link * ExopackageDexLoader#loadExopackageJars(Context, boolean)} passed true as the second arg */ public static synchronized void setupHotswap(Application application) { if (!sIsHotswapSetup) { final File dexOptDir = application.getDir("exopackage_modular_dex_opt", Context.MODE_PRIVATE); DelegatingClassLoader.getInstance().setDexOptDir(dexOptDir); application.registerReceiver( new ModularDexChangedReceiver(), ModularDexChangedReceiver.getIntentFilter(application.getPackageName())); sIsHotswapSetup = true; } }
Example 14
Source File: ConnectivityViewModel.java From 1Rramp-Android with MIT License | 4 votes |
public ConnectivityViewModel(@NonNull Application application) { super(application); application.registerReceiver(new NetworkChangeReceiver(), new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION)); }