@Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (action.equals(BluetoothAdapter.ACTION_STATE_CHANGED)) { if (intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, -1) == BluetoothAdapter.STATE_ON) { Intent refreshIntent = new Intent(ControlCenter.ACTION_REFRESH_DEVICELIST); LocalBroadcastManager.getInstance(context).sendBroadcast(refreshIntent); SharedPreferences sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context); if (!sharedPrefs.getBoolean("general_autoconnectonbluetooth", false)) { return; } GBApplication.deviceService().connect(); } else if (intent.getIntExtra(BluetoothAdapter.EXTRA_STATE, -1) == BluetoothAdapter.STATE_OFF) { GBApplication.deviceService().quit(); Intent quitIntent = new Intent(GBApplication.ACTION_QUIT); LocalBroadcastManager.getInstance(context).sendBroadcast(quitIntent); } } }
@Override public void onResume() { super.onResume(); resetNetworkInfo(); setRepoSwitchChecked(FDroidApp.isLocalRepoServiceRunnig()); LocalBroadcastManager.getInstance(this) .registerReceiver(onWifiChange, new IntentFilter(WifiStateChangeService.BROADCAST)); LocalBroadcastManager.getInstance(this) .registerReceiver(onLocalRepoChange, new IntentFilter(LocalRepoService.STATE)); // if no local repo exists, create one with only FDroid in it if (!LocalRepoManager.get(this).xmlIndex.exists()) new UpdateAsyncTask( this, new String[] { getPackageName(), }) .execute(); // start repo by default FDroidApp.startLocalRepoService(LocalRepoActivity.this); // reset the timer if viewing this Activity again if (stopTimer != null) stopTimer.cancel(); // automatically turn off after 15 minutes stopTimer = new Timer(); stopTimer.schedule( new TimerTask() { @Override public void run() { FDroidApp.stopLocalRepoService(LocalRepoActivity.this); } }, 900000); // 15 minutes }
@Override public boolean onOptionsItemSelected(MenuItem mItem) { switch (mItem.getItemId()) { case R.id.action_settings: startActivity(new Intent(this, SettingsActivity.class)); return true; case R.id.action_help: startActivity(new Intent(this, HelpActivity.class)); return true; case R.id.action_bluetooth_settings: startActivity(new Intent().setAction(Settings.ACTION_BLUETOOTH_SETTINGS)); return true; case R.id.action_bluetooth: startActivityForResult( new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE), REQUEST_ENABLE_BT); return true; case R.id.action_save: LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent(RecordFragment.SAVE_DATA)); return true; case R.id.action_clear_data: LocalBroadcastManager.getInstance(this) .sendBroadcast(new Intent(RecordFragment.CLEAR_DATA)); return true; case R.id.action_rescan: fConnect.scanForDevices(true); return true; default: return super.onOptionsItemSelected(mItem); } }
public int processEventChars(boolean var1, short var2, short var3) throws InterruptedException { long var6 = 0L; boolean var8 = false; boolean var9 = false; var6 = 0L; q var10 = new q(); var10.a = this.ftDevice.i.a; Intent intent; if (var1 && (var10.a & 1L) != 0L && (this.ftDevice.a ^ 1L) == 1L) { this.ftDevice.a |= 1L; intent = new Intent("FT_EVENT_RXCHAR"); intent.putExtra("message", "FT_EVENT_RXCHAR"); LocalBroadcastManager.getInstance(this.ftDevice.context).sendBroadcast(intent); } if (var2 != 0 && (var10.a & 2L) != 0L && (this.ftDevice.a ^ 2L) == 2L) { this.ftDevice.a |= 2L; intent = new Intent("FT_EVENT_MODEM_STATUS"); intent.putExtra("message", "FT_EVENT_MODEM_STATUS"); LocalBroadcastManager.getInstance(this.ftDevice.context).sendBroadcast(intent); } if (var3 != 0 && (var10.a & 4L) != 0L && (this.ftDevice.a ^ 4L) == 4L) { this.ftDevice.a |= 4L; intent = new Intent("FT_EVENT_LINE_STATUS"); intent.putExtra("message", "FT_EVENT_LINE_STATUS"); LocalBroadcastManager.getInstance(this.ftDevice.context).sendBroadcast(intent); } return 0; }
@Override public void onResume() { // onResume is called after onActivityCreated, when the fragment is loaded 100% Log.d(TAG, "onResume"); super.onResume(); if (map == null) { Log.w(TAG, "Map null. creating it."); setUpMap(); setupAddPlacesOverlay(); } else { Log.d(TAG, "Map already exists. Nothing to do."); } LocalBroadcastManager.getInstance(context) .registerReceiver(mMessageReceiver, new IntentFilter("LOCATION-UPDATE")); LocalBroadcastManager.getInstance(context) .registerReceiver(placesUpdateReceiver, new IntentFilter("PLACES-UPDATE")); checkLocationServiceStatus(); new UpdateMap().execute(MapUserTypes.All); cancelAsyncTasks = false; if (MainApplication.places != null) { updatePlaces(); } AnalyticsUtils.screenHit(getString(R.string.analytics_screen_map)); }
@Override public void onResume() { super.onResume(); LocalBroadcastManager.getInstance(getActivity()) .registerReceiver(mChatButtonReceiver, mChatButtonIntentFilter); LocalBroadcastManager.getInstance(getActivity()) .registerReceiver(mChatLaunchReceiver, mChatLaunchIntentFilter); }
@Override protected void loadData() { LocalBroadcastManager.getInstance(this) .registerReceiver( locationChangeReceiver, new IntentFilter("com.kplus.car.location.changed")); LocalBroadcastManager.getInstance(this) .registerReceiver(vehicleSyncReceiver, new IntentFilter(KplusConstants.ACTION_GET_SYN)); setCityAndFetchServices(); }
@Override public void onDestroy() { LocalBroadcastManager.getInstance(this).unregisterReceiver(manualActivationReceiver); LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent("service-stopped")); isRunning = false; stopForeground(true); ui.stop(); super.onDestroy(); }
public void bindBroadCastReceivers(boolean bind) { if (bind) { /* Auf Meldungen horchen, die über den Status der Verbindung zum Broker informieren */ LocalBroadcastManager.getInstance(this) .registerReceiver( mServiceStatusReceiver, new IntentFilter(Config.SERVICE_CON_STATUS_FILTER)); } else { LocalBroadcastManager.getInstance(this).unregisterReceiver(mServiceStatusReceiver); } }
private void initBroadcastReceivers() { LocalBroadcastManager.getInstance(App.getAppContext()) .unregisterReceiver(cardAddedBroadcastReceiver); LocalBroadcastManager.getInstance(App.getAppContext()) .registerReceiver(cardAddedBroadcastReceiver, new IntentFilter(ADDED_CARD_INTENT)); LocalBroadcastManager.getInstance(App.getAppContext()) .unregisterReceiver(searchCardBroadcastReceiver); LocalBroadcastManager.getInstance(App.getAppContext()) .registerReceiver(searchCardBroadcastReceiver, new IntentFilter(SEARCH_CARD_INTENT)); }
@Override public void run() { if (actionTerminated) return; stopTimer(); if (numberOfProcessedMessages < numberMessagesReceived) { startTimer(10000); Log.d( TAG, "Timer timed out by not all messages were processed. So restarting time out timer"); return; } for (Participant p : poll.getParticipants().values()) { if (AbstractAction.this instanceof SetupRoundAction) { if (!messagesReceived.containsKey(p.getUniqueId())) { // notify exclusion LocalBroadcastManager.getInstance(AndroidApplication.getInstance()) .sendBroadcast( new Intent(BroadcastIntentTypes.proofVerificationFailed) .putExtra("type", 2) .putExtra("participant", p.getIdentification())); poll.getCompletelyExcludedParticipants().put(p.getUniqueId(), p); } Log.w( TAG, "Participant " + p.getIdentification() + " (" + p.getUniqueId() + ") did not responde before timed out for submitting the setup value, so he was completely excluded (also from recovery)."); } else if (!messagesReceived.containsKey(p.getUniqueId()) && !poll.getCompletelyExcludedParticipants().containsKey(p.getUniqueId())) { poll.getExcludedParticipants().put(p.getUniqueId(), p); // notify exclusion LocalBroadcastManager.getInstance(AndroidApplication.getInstance()) .sendBroadcast( new Intent(BroadcastIntentTypes.proofVerificationFailed) .putExtra("type", 2) .putExtra("participant", p.getIdentification())); Log.w( TAG, "Excluding participant " + p.getIdentification() + " (" + p.getUniqueId() + ") because not sending his message."); } } goToNextState(); }
@Override public void onDestroy() { super.onDestroy(); LocalBroadcastManager.getInstance(this).unregisterReceiver(mVibrateReceiver); LocalBroadcastManager.getInstance(this).unregisterReceiver(mGoalReceiver); LocalBroadcastManager.getInstance(this).unregisterReceiver(mRebootReceiver); LocalBroadcastManager.getInstance(this).unregisterReceiver(mColourReceiver); LocalBroadcastManager.getInstance(this).unregisterReceiver(mBandNotificationReceiver); unregisterReceiver(bluetoothStatusChangeReceiver); mBLEComms.disconnectGatt(); }
/** * Static helper method to send broadcasts to the BaseActivity and enable or disable buttons * * @param context * @param buttonsDisabled to enable buttons apply and revert */ public static void setButtonsDisabledBroadcast(Context context, boolean buttonsDisabled) { LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(context); Intent intent = new Intent(ACTION_BUTTONS); intent.putExtra(EXTRA_BUTTONS_DISABLED, buttonsDisabled); localBroadcastManager.sendBroadcast(intent); }
@Override public void onCreate() { mNM = (NotificationManager) getSystemService(NOTIFICATION_SERVICE); mLBM = LocalBroadcastManager.getInstance(this); mLogger.info("WalletService created"); mApp = (WalletApplication) getApplicationContext(); mContext = getApplicationContext(); mRes = mContext.getResources(); mTimeoutWorker = Executors.newSingleThreadScheduledExecutor(); final String lockName = getPackageName() + " blockchain sync"; final PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); mWakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, lockName); mPrefs = PreferenceManager.getDefaultSharedPreferences(this); String fiatRateSource = mPrefs.getString(SettingsActivity.KEY_FIAT_RATE_SOURCE, ""); setFiatRateSource(fiatRateSource); // Register for future preference changes. mPrefs.registerOnSharedPreferenceChangeListener(this); // Register with the WalletApplication. mApp.setWalletService(this); }
@Override protected void onHandleIntent(Intent intent) { if (intent != null) { handleActionBiers(); LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent(MainActivity.BIERS_UPDATE)); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setRetainInstance(true); IntentFilter filter = new IntentFilter(HotelIntentService.ACAO_SINCRONIZAR); LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mServiceReceiver, filter); }
/** 保存对动态的数据,并广播给上一个activity */ private void sendBroadCastData(GroupTopicModel model) { Intent mIntent = new Intent(JLXCConst.BROADCAST_NEW_TOPIC_REFRESH); mIntent.putExtra(NEW_TOPIC_OK, model); // 发送广播 LocalBroadcastManager.getInstance(CreateGroupActivity.this).sendBroadcast(mIntent); }
@Override protected void onHandleIntent(Intent intent) { try { // [START register_for_gcm] // Initially this call goes out to the network to retrieve the // token, subsequent calls // are local. // [START get_token] InstanceID instanceID = InstanceID.getInstance(this); String token = instanceID.getToken( CommonLib.GCM_SENDER_ID, GoogleCloudMessaging.INSTANCE_ID_SCOPE, null); // TODO: Implement this method to send any registration to your // app's servers. sendRegistrationToServer(token); // Subscribe to topic channels subscribeTopics(token); ZPreferences.setIsGcmRegistered(this, true); } catch (Exception e) { ZPreferences.setIsGcmRegistered(this, false); } Intent registrationComplete = new Intent(CommonLib.GCM_TAG); LocalBroadcastManager.getInstance(this).sendBroadcast(registrationComplete); }
/** * Unregisters the survey receiver. It really important to do this, otherwise each receiver will * invoke its code. */ public void unregisterSurveysReceiver() { Log.d(TAG, "unregisterSurveysReceiver"); if (surveyReceiver != null) { LocalBroadcastManager.getInstance(getActivity()).unregisterReceiver(surveyReceiver); surveyReceiver = null; } }
@Override public void onCreate() { LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance(this); sensorManager = new MultiSensorManager(localBroadcastManager); super.onCreate(); }
@Override public void onResume() { super.onResume(); LocalBroadcastManager.getInstance(getActivity()) .registerReceiver(bcr, new IntentFilter("de.uniulm.bagception.bc.log")); updateLog(); }
@Override public void onResponse(ResponseStatus response, Object deliverParam) { if (mIsDestroy || !isAdded()) { return; } mUserInfo.photo = mBackupPhoto; if (mPhotoStatus == PhotoStatus.DELETE) { mBackupPhoto = null; mUserInfo.photo = null; } try { mUserDataProvider.setLoginUserInfo(mUserInfo.clone()); } catch (Exception e) { Log.e(TAG, " " + e.getMessage()); } LocalBroadcastManager.getInstance(mContext) .sendBroadcast(new Intent(Setting.BROADCAST_UPDATE_MYINFO)); mPopup.dismissWiat(); mPopup.show( PopupType.CONFIRM, getString(R.string.info), getString(R.string.user_modify_success), mPopupSucess, null, null); }
@Override protected void onHandleIntent(Intent intent) { SharedPreferences sharedPreferences = PreferenceManager.getDefaultSharedPreferences(this); try { synchronized (TAG) { // GCM Registration starts here // Initially this call goes out to the network to retrieve the token, subsequent // calls are local. InstanceID instanceID = InstanceID.getInstance(this); String token = instanceID.getToken( AppConstants.SENDER_ID, GoogleCloudMessaging.INSTANCE_ID_SCOPE, null); registerOnThirdPartyServer(token); // subscription to topics on which the app should accept push messages subscribeTopics(token); // This boolean value indicates that the token is already sent to 3rd party server // sharedPreferences.edit().putBoolean(SENT_TOKEN_TO_SERVER, true).apply(); sharedPreferences.edit().putString(REG_ID, token).apply(); // GCM Registration ends here } } catch (IOException e) { e.printStackTrace(); sharedPreferences.edit().putBoolean(SENT_TOKEN_TO_SERVER, false).apply(); } Intent registrationComplete = new Intent(REGISTRATION_COMPLETE); LocalBroadcastManager.getInstance(this).sendBroadcast(registrationComplete); }
private void reportResultPostProcess(String action, int processed, int modified) { Intent intent = new Intent(BROADCAST_RESULT_POSTPROCESS) .putExtra(EXTRA_RESULT_COUNTS, new int[] {processed, modified}) .putExtra(EXTRA_RESULT_ACTION, action); LocalBroadcastManager.getInstance(this).sendBroadcast(intent); }
@Override public int onStartCommand(Intent intent, int flags, int startId) { instance = this; Log.i("Jane", "Received start id " + startId + ": " + intent); Log.d("Jane", "Service received start command."); tts = new TextToSpeech( this, new TextToSpeech.OnInitListener() { @Override public void onInit(int status) {} }); tts.setOnUtteranceCompletedListener(this); // set up Bluetooth here if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) { bt = new Gingerbread(); } else { bt = new Honeycomb(); } bt.setContext(getApplicationContext()); try { bt.getProxy(); } catch (Exception e) { e.printStackTrace(); } AudioManager am = (AudioManager) getSystemService(Context.AUDIO_SERVICE); ComponentName mediaButtonResponder = new ComponentName(getPackageName(), MediaButtonIntentReceiver.class.getName()); am.registerMediaButtonEventReceiver(mediaButtonResponder); PowerManager powerManager = (PowerManager) getSystemService(Context.POWER_SERVICE); WakeLock lock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "JaneLock"); lock.acquire(10 * 60 * 1000); localBroadcastManager = LocalBroadcastManager.getInstance(this); localChatReceiver = new ChatReceiver(this); String username = intent.getExtras().getString("username"); String password = intent.getExtras().getString("password"); uiMessenger = intent.getExtras().getParcelable("messenger"); nameCache = new HashMap<String, String>(); chatCache = new HashMap<String, Chat>(); smack = org.jivesoftware.smack.SmackAndroid.init(this); this.registerReceiver(stateIntents, new IntentFilter(JaneIntent)); this.registerReceiver(stateIntents, new IntentFilter(Bluetooth.BLUETOOTH_STATE)); LoginThread login = new LoginThread(username, password, this); login.start(); return START_STICKY; }
private void reportResultPostProcess(String action, boolean result) { Intent intent = new Intent(BROADCAST_RESULT_POSTPROCESS) .putExtra(EXTRA_RESULT_RESULT, result) .putExtra(EXTRA_RESULT_ACTION, action); LocalBroadcastManager.getInstance(this).sendBroadcast(intent); }
public void performViewSetup() { final WatchViewStub stub = (WatchViewStub) layoutView.findViewById(R.id.watch_view_stub); IntentFilter messageFilter = new IntentFilter(Intent.ACTION_SEND); messageReceiver = new MessageReceiver(); localBroadcastManager = LocalBroadcastManager.getInstance(this); localBroadcastManager.registerReceiver(messageReceiver, messageFilter); stub.setOnLayoutInflatedListener( new WatchViewStub.OnLayoutInflatedListener() { @Override public void onLayoutInflated(WatchViewStub stub) { mTime = (TextView) stub.findViewById(R.id.watch_time); mSgv = (TextView) stub.findViewById(R.id.sgv); mDirection = (TextView) stub.findViewById(R.id.direction); mTimestamp = (TextView) stub.findViewById(R.id.timestamp); mUploaderBattery = (TextView) stub.findViewById(R.id.uploader_battery); mDelta = (TextView) stub.findViewById(R.id.delta); mRelativeLayout = (RelativeLayout) stub.findViewById(R.id.main_layout); mLinearLayout = (LinearLayout) stub.findViewById(R.id.secondary_layout); chart = (LineChartView) stub.findViewById(R.id.chart); layoutSet = true; mRelativeLayout.measure(specW, specH); mRelativeLayout.layout( 0, 0, mRelativeLayout.getMeasuredWidth(), mRelativeLayout.getMeasuredHeight()); } }); ListenerService.requestData(this); wakeLock.acquire(50); }
@Override public void onAttach(final Activity activity) { super.onAttach(activity); IntentFilter filter = new IntentFilter(Constants.ACTION_LOADING_START); filter.addAction(Constants.ACTION_LOADING_ENDED); LocalBroadcastManager.getInstance(activity).registerReceiver(mLoadingReceiver, filter); }
@Override public void onPause() { super.onPause(); // Unregister as broadcast receiver LocalBroadcastManager.getInstance(this).unregisterReceiver(pushNotifReceiver); }
@Override public void onPause() { super.onPause(); LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getActivity()); lbm.unregisterReceiver(mReceiver); }