List of usage examples for android.content IntentFilter IntentFilter
public IntentFilter()
From source file:com.toppatch.mv.ui.activities.LoginActivity2.java
private void enableAdmin() { DevicePolicyManager mDPM = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE); ComponentName mDeviceAdmin = new ComponentName(this, TopPatchAdmin.class); if (mDPM != null) { try {//from ww w. ja va 2 s. c om //Add filter to listen to the choice made by the user to accept the terms or not. IntentFilter filter = new IntentFilter(); filter.addAction(EnterpriseLicenseManager.ACTION_LICENSE_STATUS); actionReceiver = new SamsungReceiver(); registerReceiver(actionReceiver, filter); Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN); intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, mDeviceAdmin); intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION, "Please Activate The Admin To Let Us Steal All Your Data And Sell It To Obama!"); startActivityForResult(intent, RESULT_ENABLE); } catch (Exception e) { Log.w(TAG, "Exception: " + e); } } else { Log.e(TAG, "mDPM is null"); //TODO device doesn't support MDM...report this shit. } }
From source file:com.mobicage.rpc.http.HttpCommunicator.java
public HttpCommunicator(final MainService mainService, final Context context, final DatabaseManager databaseManager, final Credentials credentials, final ConfigurationProvider cfgProvider, final SafeRunnable onStartStashingHandler, final SafeRunnable onStopStashingHandler, final SDCardLogger sdcardLogger, final boolean wifiOnlySettingEnabled) { T.UI();/*from www .ja va 2 s. co m*/ mMainService = mainService; mCfgProvider = cfgProvider; mFinishedLock = new Object(); mStateMachineLock = new Object(); mStartStashingHandler = onStartStashingHandler; mStopStashingHandler = onStopStashingHandler; mWifiOnlyEnabled = wifiOnlySettingEnabled; mSDCardLogger = sdcardLogger; mAlarmManager = (AlarmManager) mMainService.getSystemService(Context.ALARM_SERVICE); // Create network thread for actual network communication mNetworkWorkerThread = new HandlerThread("rogerthat_net_worker"); mNetworkWorkerThread.start(); final Looper looper = mNetworkWorkerThread.getLooper(); mNetworkHandler = new Handler(looper); mNetworkHandler.post(new SafeRunnable() { @Override protected void safeRun() throws Exception { debugLog("HTTP network thread id is " + android.os.Process.myTid()); } }); final CountDownLatch latch = new CountDownLatch(1); mMainService.postAtFrontOfBIZZHandler(new SafeRunnable() { @Override public void safeRun() { T.BIZZ(); // For simplicity, I want to construct backlog on HTTP thread // This way backlog is 100% on HTTP thread mBacklog = new HttpBacklog(context, databaseManager); latch.countDown(); } }); try { latch.await(); } catch (InterruptedException e) { bugLog(e); } mBase64Username = Base64.encodeBytes(credentials.getUsername().getBytes(), Base64.DONT_BREAK_LINES); mBase64Password = Base64.encodeBytes(credentials.getPassword().getBytes(), Base64.DONT_BREAK_LINES); mMainService.addHighPriorityIntent(HttpCommunicator.INTENT_HTTP_START_OUTGOING_CALLS); if (CloudConstants.USE_GCM_KICK_CHANNEL) { final IntentFilter filter = new IntentFilter(); filter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); filter.addAction(INTENT_SHOULD_RETRY_COMMUNICATION); mMainService.registerReceiver(mBroadcastReceiver, filter); } }
From source file:com.hmsoft.bluetooth.le.DeviceControlActivity.java
private static IntentFilter makeGattUpdateIntentFilter() { // final IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(BluetoothLeService.ACTION_GATT_CONNECTED); intentFilter.addAction(BluetoothLeService.ACTION_GATT_DISCONNECTED); intentFilter.addAction(BluetoothLeService.ACTION_GATT_SERVICES_DISCOVERED); intentFilter.addAction(BluetoothLeService.ACTION_DATA_AVAILABLE); intentFilter.addAction(BluetoothDevice.ACTION_UUID); return intentFilter; }
From source file:com.cleanwiz.applock.service.LockService.java
public void registerApplicationReceiver() { IntentFilter packageIntentFilter = new IntentFilter(); IntentFilter eventIntentFilter = new IntentFilter(); eventIntentFilter.addAction(Intent.ACTION_SCREEN_OFF); eventIntentFilter.addAction(Intent.ACTION_SCREEN_ON); eventIntentFilter.addAction(Intent.ACTION_TIME_TICK); eventIntentFilter.addAction(Intent.ACTION_USER_PRESENT); eventIntentFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION); packageIntentFilter.addAction(Intent.ACTION_PACKAGE_ADDED); packageIntentFilter.addAction(Intent.ACTION_PACKAGE_REMOVED); packageIntentFilter.addDataScheme("package"); getApplicationContext().registerReceiver(packageReceiver, packageIntentFilter); getApplicationContext().registerReceiver(eventReceiver, eventIntentFilter); IntentFilter filter = new IntentFilter(); filter.addAction(LOCK_SERVICE_LASTTIME); filter.addAction(LOCK_SERVICE_LEAVEAMENT); filter.addAction(LOCK_SERVICE_LEAVERTIME); filter.addAction(LOCK_SERVICE_LOCKSTATE); lastUnlockTimeSeconds = 0;/*from w w w . j av a2 s.c o m*/ allowedLeaveAment = application.getAllowedLeaveAment(); leaverTime = application.getLeaverTime(); lockState = application.getAppLockState(); registerReceiver(new ServiceReceiver(), filter); }
From source file:com.aware.Aware.java
@Override public void onCreate() { super.onCreate(); awareContext = getApplicationContext(); aware_preferences = getSharedPreferences("aware_core_prefs", MODE_PRIVATE); if (aware_preferences.getAll().isEmpty()) { SharedPreferences.Editor editor = aware_preferences.edit(); editor.putInt(PREF_FREQUENCY_WATCHDOG, CONST_FREQUENCY_WATCHDOG); editor.putLong(PREF_LAST_SYNC, 0); editor.putLong(PREF_LAST_UPDATE, 0); editor.commit();// w w w .j a v a 2 s.c om } IntentFilter filter = new IntentFilter(); filter.addAction(Intent.ACTION_MEDIA_MOUNTED); filter.addAction(Intent.ACTION_MEDIA_UNMOUNTED); filter.addDataScheme("file"); awareContext.registerReceiver(storage_BR, filter); filter = new IntentFilter(); filter.addAction(Aware.ACTION_AWARE_CLEAR_DATA); filter.addAction(Aware.ACTION_AWARE_REFRESH); filter.addAction(Aware.ACTION_AWARE_SYNC_DATA); filter.addAction(DownloadManager.ACTION_DOWNLOAD_COMPLETE); awareContext.registerReceiver(aware_BR, filter); alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE); awareStatusMonitor = new Intent(getApplicationContext(), Aware.class); repeatingIntent = PendingIntent.getService(getApplicationContext(), 0, awareStatusMonitor, 0); alarmManager.setRepeating(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + 1000, aware_preferences.getInt(PREF_FREQUENCY_WATCHDOG, 300) * 1000, repeatingIntent); Intent synchronise = new Intent(Aware.ACTION_AWARE_SYNC_DATA); webserviceUploadIntent = PendingIntent.getBroadcast(getApplicationContext(), 0, synchronise, 0); if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) { stopSelf(); } else { SharedPreferences prefs = getSharedPreferences(getPackageName(), Context.MODE_PRIVATE); if (prefs.getAll().isEmpty() && Aware.getSetting(getApplicationContext(), Aware_Preferences.DEVICE_ID).length() == 0) { PreferenceManager.setDefaultValues(getApplicationContext(), getPackageName(), Context.MODE_PRIVATE, R.xml.aware_preferences, true); prefs.edit().commit(); //commit changes } else { PreferenceManager.setDefaultValues(getApplicationContext(), getPackageName(), Context.MODE_PRIVATE, R.xml.aware_preferences, false); } Map<String, ?> defaults = prefs.getAll(); for (Map.Entry<String, ?> entry : defaults.entrySet()) { if (Aware.getSetting(getApplicationContext(), entry.getKey()).length() == 0) { Aware.setSetting(getApplicationContext(), entry.getKey(), entry.getValue()); } } if (Aware.getSetting(getApplicationContext(), Aware_Preferences.DEVICE_ID).length() == 0) { UUID uuid = UUID.randomUUID(); Aware.setSetting(getApplicationContext(), Aware_Preferences.DEVICE_ID, uuid.toString()); } DEBUG = Aware.getSetting(awareContext, Aware_Preferences.DEBUG_FLAG).equals("true"); TAG = Aware.getSetting(awareContext, Aware_Preferences.DEBUG_TAG).length() > 0 ? Aware.getSetting(awareContext, Aware_Preferences.DEBUG_TAG) : TAG; get_device_info(); if (Aware.DEBUG) Log.d(TAG, "AWARE framework is created!"); //Fixed: only the client application does a ping to AWARE's server if (getPackageName().equals("com.aware")) { new AsyncPing().execute(); } } }
From source file:com.watch.customer.ui.ShopListActivity.java
private void initRun() { // TODO Auto-generated method stub typelistRun = new Runnable() { @Override/* ww w .ja v a 2 s .co m*/ public void run() { // TODO Auto-generated method stub String result = null; try { result = HttpUtil.get(HttpUtil.URL_TYPELIST); } catch (IOException e) { e.printStackTrace(); result = e.getMessage(); } Message msg = new Message(); msg.what = typelist_what; msg.obj = result; mHandler.sendMessage(msg); } }; ThreadPoolManager.getInstance().addTask(typelistRun); SearchBySec(); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(REFRESH_CITY); registerReceiver(MyReceiver, intentFilter); }
From source file:com.inbeacon.cordova.CordovaInbeaconManager.java
private void initEventListener() { if (broadcastReceiver != null) { // "Already listening, not adding again" return;//w w w .j a va2 s . c o m } broadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { sendUpdate(getEventObject(intent)); } }; // get all notifications from the inBeacon SDK to our broadcastReceiver IntentFilter filter = new IntentFilter(); filter.addAction("com.inbeacon.sdk.event.enterregion"); // user entered a region filter.addAction("com.inbeacon.sdk.event.exitregion"); // user left a region filter.addAction("com.inbeacon.sdk.event.enterlocation"); // user entered a location filter.addAction("com.inbeacon.sdk.event.exitlocation"); // user left a location filter.addAction("com.inbeacon.sdk.event.regionsupdate"); // region definitions were updated filter.addAction("com.inbeacon.sdk.event.enterproximity"); // user entered a beacon proximity filter.addAction("com.inbeacon.sdk.event.exitproximity"); // user left a beacon proximity filter.addAction("com.inbeacon.sdk.event.proximity"); // low level proximity update, once every second when beacons are around filter.addAction("com.inbeacon.sdk.event.appevent"); // defined in the backend for special app-specific pages to show filter.addAction("com.inbeacon.sdk.event.appaction"); // defined in the backend to handle your own local notifications LocalBroadcastManager.getInstance(cordova.getActivity().getApplicationContext()) .registerReceiver(broadcastReceiver, filter); }
From source file:com.buddi.client.dfu.DfuActivity.java
private static IntentFilter makeDfuUpdateIntentFilter() { final IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(DfuService.BROADCAST_PROGRESS); intentFilter.addAction(DfuService.BROADCAST_ERROR); intentFilter.addAction(DfuService.BROADCAST_LOG); return intentFilter; }
From source file:com.dsna.android.main.MainActivity.java
@Override protected void onResume() { super.onResume(); Intent intent = new Intent(this, AndroidSocialService.class); intent.putExtra(bIp, mBootIp);/*from www .j av a 2s . c o m*/ intent.putExtra(bPort, mBootPort); intent.putExtra(biPort, mBindPort); intent.putExtra(uName, mUsername); LocalBroadcastManager bManager = LocalBroadcastManager.getInstance(this); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(AndroidSocialService.RECEIVE_ENTITY); intentFilter.addAction(AndroidSocialService.DISPLAY_TOAST); bManager.registerReceiver(bReceiver, intentFilter); System.out.println("Prepare to bind service"); bindService(intent, mConnection, Context.BIND_AUTO_CREATE); }
From source file:com.poinsart.votar.VotarMain.java
@Override protected void onResume() { super.onResume(); IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION); registerReceiver(broadcastReceiver, intentFilter); updateWifiStatus();/* w ww. j a va 2 s. c o m*/ }