@Override public void onNotificationPosted(StatusBarNotification sbn) { String pack = sbn.getPackageName(); String ticker = sbn.getNotification().tickerText.toString(); Bundle extras = sbn.getNotification().extras; String title = extras.getString("android.title"); String text = extras.getCharSequence("android.text").toString(); Log.i("Package",pack); Log.i("Ticker",ticker); Log.i("Title",title); Log.i("Text",text); Intent msgrcv = new Intent("Msg"); msgrcv.putExtra("package", pack); msgrcv.putExtra("ticker", ticker); msgrcv.putExtra("title", title); msgrcv.putExtra("text", text); LocalBroadcastManager.getInstance(context).sendBroadcast(msgrcv); }
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_station_lobby, container, false); IntentFilter filter = new IntentFilter(); filter.addAction(StationActivity.ACTION_MAIN_SERVICE_BOUND); LocalBroadcastManager bm = LocalBroadcastManager.getInstance(getContext()); bm.registerReceiver(mBroadcastReceiver, filter); lobbiesLayout = (LinearLayout) view.findViewById(R.id.lobbies_layout); update(); return view; }
@Test public void checksOnEventReceivedPushNotCalledWhenTelemetryDisabled() throws Exception { Context mockedContext = mock(Context.class, RETURNS_DEEP_STUBS); MapboxTelemetry.applicationContext = mockedContext; String aValidAccessToken = "validAccessToken"; String aValidUserAgent = "MapboxTelemetryAndroid/"; EventsQueue mockedEventsQueue = mock(EventsQueue.class); TelemetryClient mockedTelemetryClient = mock(TelemetryClient.class); Callback mockedHttpCallback = mock(Callback.class); SchedulerFlusher mockedSchedulerFlusher = mock(SchedulerFlusher.class); Clock mockedClock = mock(Clock.class); LocalBroadcastManager mockedLocalBroadcastManager = mock(LocalBroadcastManager.class); boolean indifferentServiceBound = true; MapboxTelemetry theMapboxTelemetry = new MapboxTelemetry(mockedContext, aValidAccessToken, aValidUserAgent, mockedEventsQueue, mockedTelemetryClient, mockedHttpCallback, mockedSchedulerFlusher, mockedClock, mockedLocalBroadcastManager, indifferentServiceBound); Event mockedEvent = mock(Event.class); theMapboxTelemetry.onEventReceived(mockedEvent); verify(mockedEventsQueue, never()).push(eq(mockedEvent)); }
/** * @param action */ private final void registerReceiverAction(final String action) { IntentFilter filter = new IntentFilter(action); LocalBroadcastManager.getInstance(mContext).registerReceiver(new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (action.equals(intent.getAction())) { PluginInfo info = intent.getParcelableExtra("obj"); if (info != null) { switch (action) { case ACTION_NEW_PLUGIN: // 非常驻进程上下文 newPluginFound(info, intent.getBooleanExtra(RePluginConstants.KEY_PERSIST_NEED_RESTART, false)); break; case ACTION_UNINSTALL_PLUGIN: pluginUninstalled(info); break; } } } } }, filter); }
@Override public void onDestroy() { if (server != null) { try { LocalBroadcastManager.getInstance(this).unregisterReceiver(messageReceiver); // server.stop(); server.shutdownNow(); server = null; Intent statusIntent = new Intent(DeskDroidService.SERVER_STATUS_CHANGE); statusIntent.putExtra("running", false); LocalBroadcastManager.getInstance(this).sendBroadcast(statusIntent); } catch (Exception e) { } } super.onDestroy(); }
public AndroidJSTPConnection(String host, int port, boolean usesSSL, Context context) { mListeners = new CopyOnWriteArrayList<>(); mTaggedCacheCalls = new ConcurrentHashMap<>(); mConnectionState = STATE_NOT_CONNECTED; mNeedsRestoration = true; mContext = context; TCPTransport transport = new TCPTransport(host, port, usesSSL); mConnection = new Connection(transport, this); mConnection.addSocketListener(this); mBroadcastManager = LocalBroadcastManager.getInstance(mContext); initNetworkReceiver(); }
@Override public void onMessageReceived(MessageEvent messageEvent) { if (messageEvent.getPath().equals("/heartRate")) { final String message = new String(messageEvent.getData()); Log.v("pactchat", "Message path received on watch is: " + messageEvent.getPath()); Log.v("packtchat", "Message received on watch is: " + message); // Broadcast message to wearable activity for display Intent messageIntent = new Intent(); messageIntent.setAction(Intent.ACTION_SEND); messageIntent.putExtra("heart", message); LocalBroadcastManager.getInstance(this).sendBroadcast(messageIntent); } else { super.onMessageReceived(messageEvent); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); s = new Setting(); Language = s.getLang(); SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getBaseContext()); Language = preferences.getString("l",Language); setLanguage(Language); setContentView(R.layout.activity_main); BottomNavigationView navigation = findViewById(R.id.navigation); navigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener); fm=getSupportFragmentManager(); fm.beginTransaction().add(R.id.content,new BlankFragment()).commit(); Intent i = new Intent(this,SocketService.class); bindService(i,myConnection,Context.BIND_AUTO_CREATE); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); Log.e("Brodcast","Broadcast intent onCreate invoked"); if(savedInstanceState == null){ if(!registred){ LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver, new IntentFilter("my-event")); Log.e("Registre","Broadcast intent register"); registred = true; }} }
/** * Cleanup the object * Should be called when the object is not used anymore */ public void cleanup() { stopDiscovering(); //close discovery service Log.d(TAG, "closeServices ..."); if (mArdiscoveryService != null) { new Thread(new Runnable() { @Override public void run() { mArdiscoveryService.stop(); mCtx.unbindService(mArdiscoveryServiceConnection); mArdiscoveryService = null; } }).start(); } // unregister receivers LocalBroadcastManager localBroadcastMgr = LocalBroadcastManager.getInstance(mCtx); localBroadcastMgr.unregisterReceiver(mArdiscoveryServicesDevicesListUpdatedReceiver); }
@Override public void onNotifactionShowedResult(Context context, XGPushShowedResult xgPushShowedResult) { LogUtils.d(TAG, xgPushShowedResult.toString()); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss", Locale.CHINA); Notice notice = new Notice(); notice.setTitle(xgPushShowedResult.getTitle()); notice.setContent(xgPushShowedResult.getContent()); notice.setTime(simpleDateFormat.format(new Date())); notice.setUserId(getLoginUser()); NoticeDao noticeDao = getDaoSession().getNoticeDao(); noticeDao.insert(notice); //发送广播通知更新 Intent intent = new Intent(Constants.mainBroadcast); Bundle bundle = new Bundle(); bundle.putInt("type", Constants.BROADCAST_TYPE_NOTICE); intent.putExtras(bundle); LocalBroadcastManager.getInstance(context).sendBroadcast(intent); }
@Test public void checksUserAgentEvents() throws Exception { Context mockedContext = mock(Context.class, RETURNS_DEEP_STUBS); MapboxTelemetry.applicationContext = mockedContext; String aValidAccessToken = "validAccessToken"; String theEventsAndroidAgent = "MapboxEventsAndroid/"; EventsQueue mockedEventsQueue = mock(EventsQueue.class); TelemetryClient mockedTelemetryClient = mock(TelemetryClient.class); Callback mockedHttpCallback = mock(Callback.class); SchedulerFlusher mockedSchedulerFlusher = mock(SchedulerFlusher.class); Clock mockedClock = mock(Clock.class); LocalBroadcastManager mockedLocalBroadcastManager = mock(LocalBroadcastManager.class); boolean indifferentServiceBound = true; MapboxTelemetry theMapboxTelemetry = new MapboxTelemetry(mockedContext, aValidAccessToken, theEventsAndroidAgent, mockedEventsQueue, mockedTelemetryClient, mockedHttpCallback, mockedSchedulerFlusher, mockedClock, mockedLocalBroadcastManager, indifferentServiceBound); theMapboxTelemetry.enable(); boolean validRequiredParameters = theMapboxTelemetry.checkRequiredParameters(aValidAccessToken, theEventsAndroidAgent); assertTrue(validRequiredParameters); }
@Override public void run() { try { sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } LocalBroadcastManager _manager = LocalBroadcastManager.getInstance(Global.get_applicationContext()); SDFile _file; for (int _temp_i = 0; _temp_i < _files.size(); _temp_i++) { _file = _files.valueAt(_temp_i); _file.updateRubbish(); Intent _update = new Intent(ACTION_UPDATE); _update.putExtra("index", _files.keyAt(_temp_i)); _manager.sendBroadcast(_update); } Intent _finish = new Intent(ACTION_FINISH); _manager.sendBroadcast(_finish); }
@Test public void checksInvalidUserAgent() throws Exception { Context mockedContext = mock(Context.class, RETURNS_DEEP_STUBS); MapboxTelemetry.applicationContext = mockedContext; String aValidAccessToken = "validAccessToken"; String aInvalidUserAgent = "invalidUserAgent"; EventsQueue mockedEventsQueue = mock(EventsQueue.class); TelemetryClient mockedTelemetryClient = mock(TelemetryClient.class); Callback mockedHttpCallback = mock(Callback.class); SchedulerFlusher mockedSchedulerFlusher = mock(SchedulerFlusher.class); Clock mockedClock = mock(Clock.class); LocalBroadcastManager mockedLocalBroadcastManager = mock(LocalBroadcastManager.class); boolean indifferentServiceBound = true; MapboxTelemetry theMapboxTelemetry = new MapboxTelemetry(mockedContext, aValidAccessToken, aInvalidUserAgent, mockedEventsQueue, mockedTelemetryClient, mockedHttpCallback, mockedSchedulerFlusher, mockedClock, mockedLocalBroadcastManager, indifferentServiceBound); theMapboxTelemetry.enable(); boolean validRequiredParameters = theMapboxTelemetry.checkRequiredParameters(aValidAccessToken, aInvalidUserAgent); assertFalse(validRequiredParameters); }
static AccessTokenManager getInstance() { if (instance == null) { synchronized (AccessTokenManager.class) { if (instance == null) { Context applicationContext = FacebookSdk.getApplicationContext(); LocalBroadcastManager localBroadcastManager = LocalBroadcastManager.getInstance( applicationContext); AccessTokenCache accessTokenCache = new AccessTokenCache(); instance = new AccessTokenManager(localBroadcastManager, accessTokenCache); } } } return instance; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_list_with_header); // Get the list component from the layout of the activity final WearableListView listView = (WearableListView) findViewById(R.id.devices_list); listView.setAdapter(mDeviceAdapter = new DevicesAdapter(listView)); listView.setClickListener(mOnRowClickListener); listView.addOnScrollListener(mOnScrollListener); // The header will be moved as the list is scrolled mHeader = findViewById(R.id.header); // Register a broadcast receiver that will listen for events from the service. LocalBroadcastManager.getInstance(this).registerReceiver(mServiceBroadcastReceiver, BleProfileService.makeIntentFilter()); }
@Override public void onCreate() { super.onCreate(); Utils.debugLog(TAG, "creating Service"); localBroadcastManager = LocalBroadcastManager.getInstance(this); appUpdateStatusManager = AppUpdateStatusManager.getInstance(this); BroadcastReceiver br = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String packageName = intent.getData().getSchemeSpecificPart(); for (AppUpdateStatusManager.AppUpdateStatus status : appUpdateStatusManager.getByPackageName(packageName)) { appUpdateStatusManager.updateApk(status.getUniqueKey(), AppUpdateStatusManager.Status.Installed, null); } } }; IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(Intent.ACTION_PACKAGE_ADDED); intentFilter.addDataScheme("package"); registerReceiver(br, intentFilter); }
@Override public void onDestroy() { super.onDestroy(); if (mNotificationManager != null) { stopForeground(true); } else { stopSelf(); } try { unregisterReceiver(mBroadcastReceiver); LocalBroadcastManager.getInstance(this).unregisterReceiver(mBroadcastReceiver); } catch (Throwable t) { t.printStackTrace(); } mHandlerThread.quit(); }
@Override public void onCreate() { super.onCreate(); LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(phoneReceiver,new IntentFilter("receive_incoming_call")); LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(phoneReceiver,new IntentFilter("rejected_incoming_call")); LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(phoneReceiver,new IntentFilter("EXTRA_STATE_OFFHOOK")); //media player intents IntentFilter mediaPlayerFilter = new IntentFilter(); mediaPlayerFilter.addAction(AppConstants.MediaPlayer.PLAY); mediaPlayerFilter.addAction(AppConstants.MediaPlayer.PAUSE); mediaPlayerFilter.addAction(AppConstants.MediaPlayer.BACK); mediaPlayerFilter.addAction(AppConstants.MediaPlayer.FORWARD); mediaPlayerFilter.addAction(AppConstants.MediaPlayer.STOP); mediaPlayerFilter.addAction(AppConstants.MediaPlayer.REPEAT_ON); mediaPlayerFilter.addAction(AppConstants.MediaPlayer.REPEAT_OFF); mediaPlayerFilter.addAction(Intent.ACTION_NEW_OUTGOING_CALL); registerReceiver(MediaPlayerBroadcast, mediaPlayerFilter); //screen on / of guard key unlock flag IntentFilter screenIntentFilter = new IntentFilter(Intent.ACTION_SCREEN_ON); screenIntentFilter.addAction(Intent.ACTION_SCREEN_ON); screenIntentFilter.addAction(Intent.ACTION_SCREEN_OFF); screenIntentFilter.addAction(Intent.ACTION_USER_PRESENT); registerReceiver(MediaPlayerNotificationShow, screenIntentFilter); }
private void callPvDataService() { BroadcastReceiver broadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { LocalBroadcastManager.getInstance(context).unregisterReceiver(this); if (intent.getBooleanExtra("success", true)) { updateScreen(); } else { Toast.makeText(context, intent.getStringExtra("message"), Toast.LENGTH_LONG).show(); } } }; IntentFilter intentFilter = new IntentFilter(PvDataService.class.getName()); LocalBroadcastManager.getInstance(getContext()) .registerReceiver(broadcastReceiver, intentFilter); PvDataService.callDay(getContext(), picked.year, picked.month); }
private void sendProgressBroadcast(final int progress) { final long now = SystemClock.elapsedRealtime(); final float speed = now - mLastProgressTime != 0 ? (float) (mBytesSent - mLastBytesSent) / (float) (now - mLastProgressTime) : 0.0f; final float avgSpeed = now - mStartTime != 0 ? (float) mBytesSent / (float) (now - mStartTime) : 0.0f; mLastProgressTime = now; mLastBytesSent = mBytesSent; final Intent broadcast = new Intent(BROADCAST_PROGRESS); broadcast.putExtra(EXTRA_DATA, progress); broadcast.putExtra(EXTRA_DEVICE_ADDRESS, mDeviceAddress); broadcast.putExtra(EXTRA_PART_CURRENT, mPartCurrent); broadcast.putExtra(EXTRA_PARTS_TOTAL, mPartsTotal); broadcast.putExtra(EXTRA_SPEED_B_PER_MS, speed); broadcast.putExtra(EXTRA_AVG_SPEED_B_PER_MS, avgSpeed); LocalBroadcastManager.getInstance(this).sendBroadcast(broadcast); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_home); initFragment(); //display the fragment home witout any value //init the sensors sensorManager=(SensorManager) getSystemService(SENSOR_SERVICE); sensor_pulse=sensorManager.getDefaultSensor(Sensor.TYPE_HEART_RATE); sensor_step=sensorManager.getDefaultSensor(Sensor.TYPE_STEP_DETECTOR); //register the sensors sensorManager.registerListener(this,sensor_step,SensorManager.SENSOR_DELAY_NORMAL); //activate a thread for the pulse sensors //process information: 30 sec //stop time= 30 min threadPulse=new SensorsThreadLifecircle(this,sensor_pulse,30000,1000*60*30); threadPulse.start(); displayFragmentHome(); // Register the local broadcast receiver. make the ling between the Service and the view IntentFilter messageFilter = new IntentFilter(Intent.ACTION_SEND); MessageReceiver messageReceiver = new MessageReceiver(); LocalBroadcastManager.getInstance(this).registerReceiver(messageReceiver, messageFilter); }
@Override public void onResponse(String response) { if (!mUploadFragment.isAdded()) { return; } mUploadFragment.progressEnd(); String resultString = mUploadFragment.genShareText(response); mUploadFragment.setResultText(resultString); mUploadFragment.setMainInfo(R.string.share_success); ClipboardManager clipboardManager = (ClipboardManager) getSystemService(Context .CLIPBOARD_SERVICE); ClipData data = ClipData.newPlainText(CLIP_LABEL, resultString); clipboardManager.setPrimaryClip(data); mUploadFragment.setBackgroundClickListener(null); mUploadFragment.setListener(new OnClickListener() { @Override public void onClick(View v) { Intent intent = new Intent(); intent.setAction(INTENT_START_CAMERA_ACTIVITY); intent.putExtra(BITMAP_FILE, saveFilePath); LocalBroadcastManager.getInstance(EditImageActivity.this).sendBroadcast(intent); finish(); } }); Log.d(TAG, String.valueOf(response)); }
/** * Function to draw saved highlight */ public void drawSavedHighlight() { try { //get ayaInfo to highlight String[] ayaInfo = AppPreference.getSelectionVerse().split("-"); if (ayaInfo != null) { //split ayaInfo to extract information int suraID = Integer.parseInt(ayaInfo[2]); int ayaID = Integer.parseInt(ayaInfo[1]); int pageNumber = Integer.parseInt(ayaInfo[0]); Log.d("draw_image", suraID + "--" + ayaID + "--" + pageNumber); Intent highlightAya = new Intent(AppConstants.Highlight.INTENT_FILTER); highlightAya.putExtra(AppConstants.Highlight.VERSE_NUMBER, ayaID); highlightAya.putExtra(AppConstants.Highlight.SORA_NUMBER, suraID); highlightAya.putExtra(AppConstants.Highlight.PAGE_NUMBER, pageNumber); LocalBroadcastManager.getInstance(getContext()).sendBroadcast(highlightAya); } } catch (Exception e) { } }
@Test public void checksSendEventImmediatelyIfWhitelisted() throws Exception { Context mockedContext = obtainNetworkConnectedMockedContext(); MapboxTelemetry.applicationContext = mockedContext; String aValidAccessToken = "validAccessToken"; String aValidUserAgent = "MapboxTelemetryAndroid/"; EventsQueue mockedEventsQueue = mock(EventsQueue.class); TelemetryClient mockedTelemetryClient = mock(TelemetryClient.class); Callback mockedHttpCallback = mock(Callback.class); SchedulerFlusher mockedSchedulerFlusher = mock(SchedulerFlusher.class); Clock mockedClock = mock(Clock.class); LocalBroadcastManager mockedLocalBroadcastManager = mock(LocalBroadcastManager.class); boolean indifferentServiceBound = true; MapboxTelemetry theMapboxTelemetry = new MapboxTelemetry(mockedContext, aValidAccessToken, aValidUserAgent, mockedEventsQueue, mockedTelemetryClient, mockedHttpCallback, mockedSchedulerFlusher, mockedClock, mockedLocalBroadcastManager, indifferentServiceBound); Event whitelistedEvent = new AppUserTurnstile(true, "anySdkIdentifier", "anySdkVersion"); ArgumentCaptor<List<Event>> eventsCaptor = ArgumentCaptor.forClass((Class) List.class); theMapboxTelemetry.enable(); theMapboxTelemetry.push(whitelistedEvent); verify(mockedTelemetryClient, times(1)).sendEvents(eventsCaptor.capture(), eq(mockedHttpCallback)); assertEquals(eventsCaptor.getValue().get(0), whitelistedEvent); }
@Override public void onDestroy() { mDbHelper.close(); super.onDestroy(); //unregister the broadcast receiver LocalBroadcastManager.getInstance(getActivity()).unregisterReceiver(mBroadcastReceiver); }
protected void onDestroy() { MQUtils.closeKeyboard((Activity) this); try { this.mSoundPoolManager.release(); LocalBroadcastManager.getInstance(this).unregisterReceiver(this.mMessageReceiver); unregisterReceiver(this.mNetworkChangeReceiver); } catch (Exception e) { } this.isDestroy = true; cancelAllDownload(); super.onDestroy(); }
private void notifyMainActivity(String status) { Log.d(TAG,"notifyMainActivity("+status+") entry."); // Let the Main Activity know we are playing the song. Intent playingIntent = new Intent(status); int trackIndex = 0; if (playingIndexInfo != null) trackIndex = playingIndexInfo.getTrackIndex(); playingIntent.putExtra("songIndex", trackIndex); LocalBroadcastManager.getInstance(this).sendBroadcast(playingIntent); }
private void onUpdatesSaved(int accountId, VkApiLongpollUpdates updates) { LongPollNotificationHelper.fireUpdates(this, accountId, updates); ArrayList<AbsRealtimeAction> actions = createActions(accountId, updates); if (nonEmpty(actions)) { Intent intent = new Intent(WHAT_REALTIME_ACTIONS); intent.putParcelableArrayListExtra(EXTRA_REALTIME_ACTIONS, actions); LocalBroadcastManager.getInstance(this).sendBroadcast(intent); } }
@Override public void onHandleIntent(Intent i) { try { //checar se tem permissao... Android 6.0+ File root = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS); root.mkdirs(); File output = new File(root, i.getData().getLastPathSegment()); if (output.exists()) { output.delete(); } URL url = new URL(i.getData().toString()); HttpURLConnection c = (HttpURLConnection) url.openConnection(); FileOutputStream fos = new FileOutputStream(output.getPath()); BufferedOutputStream out = new BufferedOutputStream(fos); try { InputStream in = c.getInputStream(); byte[] buffer = new byte[8192]; int len = 0; while ((len = in.read(buffer)) >= 0) { out.write(buffer, 0, len); } out.flush(); } finally { fos.getFD().sync(); out.close(); c.disconnect(); } LocalBroadcastManager.getInstance(this).sendBroadcast(new Intent(DOWNLOAD_COMPLETE)); } catch (IOException e2) { Log.e(getClass().getName(), "Exception durante download", e2); } }
@Override protected void onPause() { if (BuildConfig.LOG_DEBUG) LogUtils.d(TAG); super.onPause(); LocalBroadcastManager bm = LocalBroadcastManager.getInstance(this); bm.unregisterReceiver(receiver); }
@Override public void onPause() { if (downloadReceiver != null) { downloadReceiver.setListener(null); LocalBroadcastManager.getInstance(this) .unregisterReceiver(downloadReceiver); downloadReceiver = null; } super.onPause(); }
@Override protected void onResume() { super.onResume(); Utils.logD(LOG_TAG, "onResume"); IntentFilter filter = new IntentFilter(GPSTrackerFragment.BROADCAST); LocalBroadcastManager.getInstance(this).registerReceiver(launcherBroadcast, filter); if (mRadioChanged) { mRadioChanged = false; addFragment(0); getTrackFragment().restartTimeCounter(); } }
public MusicFromSingerAndAlbum(Context context,int num,String name){ this.listContainer = LayoutInflater.from(context); this.mcontext = context; this.global = (GlobalVariable) context.getApplicationContext(); if (name.equals("singer")){ this.musiclist = global.getSingerListList().get(num).getMusicListBelongSinger(); } if (name.equals("album")){ this.musiclist = global.getAlbumListList().get(num).getMusicListBelongAlbum(); } this.localBroadcastManager = LocalBroadcastManager.getInstance(context); }
@Override protected void onDestroy() { super.onDestroy(); mPresenter.unregister(); LocalBroadcastManager.getInstance(this).unregisterReceiver(mReceiver); }
@Override public void onAttach(final Activity activity) { super.onAttach(activity); final WalletApplication application = ((AbstractWalletActivity) activity).getWalletApplication(); this.wallet = application.getWallet(); this.broadcastManager = LocalBroadcastManager.getInstance(activity); }
@Override public void onCreate(Bundle savedInstanceState) { Log.d(TAG, "onCreate SetupFragment"); super.onCreate(savedInstanceState); LocalBroadcastManager.getInstance(getActivity()).registerReceiver( mSyncStatusChangedReceiver, new IntentFilter(SyncJobService.ACTION_SYNC_STATUS_CHANGED)); mInputId = getActivity().getIntent().getStringExtra(TvInputInfo.EXTRA_INPUT_ID); new SetupRowTask().execute(); }
private void uiInitWifi() { viewWifiId = (TextView) findViewById(R.id.device_id_wifi); viewWifiNetwork = (TextView) findViewById(R.id.wifi_network); wifiSwitch = (SwitchCompat) findViewById(R.id.switch_wifi); wifiSwitch.setOnCheckedChangeListener(onWifiSwitchToggled); setWifiSwitchState(getManager().isBonjourDiscoverable(), true); textWifiVisible = (TextView) findViewById(R.id.wifi_visible); int textResource = getManager().isBonjourDiscoverable() ? R.string.swap_visible_wifi : R.string.swap_not_visible_wifi; textWifiVisible.setText(textResource); // Note that this is only listening for the WifiSwap, whereas we start both the WifiSwap // and the Bonjour service at the same time. Technically swap will work fine without // Bonjour, and that is more of a convenience. Thus, we should show feedback once wifi // is ready, even if Bonjour is not yet. LocalBroadcastManager.getInstance(getContext()).registerReceiver(onWifiSwapStateChanged, new IntentFilter(SwapService.WIFI_STATE_CHANGE)); viewWifiNetwork.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { getActivity().promptToSelectWifiNetwork(); } }); uiUpdateWifiNetwork(); }
@Override public void onCreate() { geocoder = new Geocoder(LocationService.this, Locale.getDefault()); locationString = getResources().getString(R.string.unknown_location); locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); localBroadcastManager = LocalBroadcastManager.getInstance(this); }
ProfileManager( LocalBroadcastManager localBroadcastManager, ProfileCache profileCache) { Validate.notNull(localBroadcastManager, "localBroadcastManager"); Validate.notNull(profileCache, "profileCache"); this.localBroadcastManager = localBroadcastManager; this.profileCache = profileCache; }
@Override protected void onStart() { super.onStart(); if (Build.VERSION.SDK_INT >= 23) { int permissionWriteCheck = ContextCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE); int permissionReadCheck = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE); if (permissionWriteCheck == PackageManager.PERMISSION_DENIED || permissionReadCheck == PackageManager.PERMISSION_DENIED) { ActivityCompat.requestPermissions( this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE}, PERMISSION_REQUEST_CODE); permissionReady = false; } else { permissionReady = true; } } else { permissionReady = true; } if (permissionReady == true) { loadSmings(); Constant.makeAppDefaultDirectory(this); unzipFonts(); } loadAttacks(); if (MusicListenService.isServiceRunning() == true) { fab.setSelected(true); } else { fab.setSelected(false); } IntentFilter intentFilter = new IntentFilter(MusicListenService.ACTION_STOP); LocalBroadcastManager.getInstance(this).registerReceiver(mBroadcastReceiver, intentFilter); checkEmpty(); checkPlayList(); }