List of usage examples for android.content BroadcastReceiver BroadcastReceiver
public BroadcastReceiver()
From source file:com.jaus.albertogiunta.justintrain_oraritreni.journeyFavourites.FavouriteJourneysActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_favourite_journeys); ButterKnife.bind(this); analyticsHelper = AnalyticsHelper.getInstance(getViewContext()); iabHelper = CustomIABHelper.getInstance(FavouriteJourneysActivity.this, this); checkIntro();/*from w w w. jav a 2 s .c om*/ Log.d("onCreate token : " + FirebaseInstanceId.getInstance().getToken()); // MigrationHelper.migrateIfDue(getViewContext()); presenter = new FavouritesPresenter(this); checkIntent(getIntent()); new Handler().postDelayed(() -> { fetchRemoteConfigs(); }, 0); ActionBar actionBar = getSupportActionBar(); if (actionBar != null) { actionBar.setTitle(R.string.title_favourite_journeys); } ShortcutHelper.updateShortcuts(getViewContext()); adapter = new FavouriteJourneysAdapter(presenter.getRecyclerViewList(), getViewContext()); rvFavouriteJourneys.setAdapter(adapter); rvFavouriteJourneys.setLayoutManager(new LinearLayoutManager(this)); adapter.setSwipeEnabled(true); btnSearch.setScaleX(0); btnSearch.setScaleY(0); new Handler().postDelayed(() -> AnimationUtils.onCompare(btnSearch), 500); rvFavouriteJourneys.addOnScrollListener(new HideShowScrollListener() { @Override public void onHide() { btnSearch.animate().setInterpolator(new AccelerateDecelerateInterpolator()).translationY(600) .setDuration(150); btnIAP.animate().setInterpolator(new AccelerateDecelerateInterpolator()).translationY(600) .setDuration(150); } @Override public void onShow() { btnSearch.animate().setInterpolator(new AccelerateDecelerateInterpolator()).translationY(0) .setDuration(150); btnIAP.animate().setInterpolator(new AccelerateDecelerateInterpolator()).translationY(0) .setDuration(150); } }); messageReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { showSnackbar(intent.getExtras().getString(NotificationService.NOTIFICATION_ERROR_MESSAGE), NONE, Snackbar.LENGTH_SHORT); } }; apply(btnIAP, GONE); btnIAP.setOnClickListener(v -> { analyticsHelper.logScreenEvent(SCREEN_FAVOURITE_JOURNEYS, IAP_SEARCH); Intent i = new Intent(FavouriteJourneysActivity.this, LicenseUpgradeActivity.class); FavouriteJourneysActivity.this.startActivity(i); }); if (ignoreBeingProAndShowAds) { apply(btnIAP, VISIBLE); loadAds(); } AsyncTask task = new LoadCursorTask(this).execute(); startService(new Intent(this, NotificationService.class)); }
From source file:com.nexmo.sdk.verify.ui.CheckPhoneNumberActivity.java
/** * Hide the cancel/try another sms/call instead buttons until after 30seconds the verification has started. *//*from w w w . j a v a 2 s . c o m*/ private void setupCommands() { this.cancelButton = (Button) findViewById(R.id.cancel_btn); this.tryAgainButton = (Button) findViewById(R.id.try_again_btn); this.callInsteadButton = (Button) findViewById(R.id.call_instead_btn); this.verifyClientBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { // command timer finished Bundle extras = intent.getExtras(); if (extras != null && extras.containsKey(VerifyClient.MESSAGE_KEY_TIMER_STATE_DONE)) { cancelButton.setVisibility(View.VISIBLE); callInsteadButton.setVisibility(View.VISIBLE); tryAgainButton.setVisibility(View.VISIBLE); } } }; LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver( this.verifyClientBroadcastReceiver, new IntentFilter(VerifyClient.ACTION_BROADCAST_COMMAND_TIMER)); }
From source file:com.kasungunathilaka.sarigama.fragment.ArtistDetailFragment.java
@Override public void onResume() { super.onResume(); broadcastReceiver = new BroadcastReceiver() { @Override//from www . ja v a2 s . c o m public void onReceive(Context context, Intent intent) { Bundle bundle; switch (intent.getAction()) { case HomeActivity.ON_ADDED_TO_QUEUE: if (!activity.getPlayerService().isPlaying()) { bundle = new Bundle(); bundle.putBoolean(PlayerFragment.PREVIOUS_AUDIO, false); bundle.putString(HomeActivity.FRAGMENT_NAME, "PlayerFragment"); iFragmentCommunicator.fragmentData(bundle); } break; case HomeActivity.ON_SAME_ADDED_TO_QUEUE: bundle = new Bundle(); bundle.putBoolean(PlayerFragment.PREVIOUS_AUDIO, true); bundle.putString(HomeActivity.FRAGMENT_NAME, "PlayerFragment"); iFragmentCommunicator.fragmentData(bundle); break; case HomeActivity.ON_CURRENT_POSITION_CHANGED: bundle = new Bundle(); bundle.putBoolean(PlayerFragment.PREVIOUS_AUDIO, false); bundle.putString(HomeActivity.FRAGMENT_NAME, "PlayerFragment"); iFragmentCommunicator.fragmentData(bundle); break; } } }; LocalBroadcastManager.getInstance(getActivity()).registerReceiver((broadcastReceiver), new IntentFilter(HomeActivity.ON_ADDED_TO_QUEUE)); LocalBroadcastManager.getInstance(getActivity()).registerReceiver((broadcastReceiver), new IntentFilter(HomeActivity.ON_SAME_ADDED_TO_QUEUE)); LocalBroadcastManager.getInstance(getActivity()).registerReceiver((broadcastReceiver), new IntentFilter(HomeActivity.ON_CURRENT_POSITION_CHANGED)); }
From source file:com.jins_meme.bridge.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Fabric.with(this, new Crashlytics()); setContentView(R.layout.activity_bridge_menu); handler = new Handler(); mainLayout = (FrameLayout) findViewById(R.id.container); preferences = PreferenceManager.getDefaultSharedPreferences(this); editor = preferences.edit();/* w ww . j av a 2 s . co m*/ if (getSupportActionBar() != null) { //updateActionBar(getResources().getString(R.string.actionbar_title)); updateActionBarLogo(isCameraMenuFragment); } // Only use for Eye VDJ /* View decor = this.getWindow().getDecorView(); decor.setSystemUiVisibility(View.SYSTEM_UI_FLAG_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE); */ rootMenu = new RootMenuFragment(); spotifyMenu = new SpotifyMenuFragment(); hueMenu = new HueMenuFragment(); vdjMenu = new VDJMenuFragment(); remoMenu = new RemoMenuFragment(); cameraMenu = new CameraMenuFragment(); interactionDisableTimer.setListener(this); cancelTimer.setListener(this); pauseTimer.setListener(this); ((PauseActionDetector) findViewById(R.id.interceptor)).setListaner(this); basicConfigFragment = new BasicConfigFragment(); oscConfigFragment = new OSCConfigFragment(); midiConfigFragment = new MIDIConfigFragment(); spotifyConfigFragment = new SpotifyConfigFragment(); hueConfigFragment = new HueConfigFragment(); remoConfigFragment = new RemoConfigFragment(); aboutFragment = new AboutFragment(); /* * MODIFY YOURSELF * Add your implemented function's configuration * */ // ***ConfigFragment = new ***ConfigFragment FragmentManager manager = getSupportFragmentManager(); FragmentTransaction transaction = manager.beginTransaction(); transaction.add(R.id.container, rootMenu); transaction.commit(); if (preferences.getBoolean("SHOW_WELCOME", true)) { showWelcom(); } else { if (Build.VERSION.SDK_INT >= 23) { requestGPSPermission(); } } mNetworkStateReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (mPlayer != null) { Connectivity connectivity = getNetworkConnectivity(context); mPlayer.setConnectivityStatus(mOperationCallback, connectivity); } } }; }
From source file:com.tourmaline.example.activities.MainActivity.java
private void registerEngineAlerts() { final LocalBroadcastManager mgr = LocalBroadcastManager.getInstance(this); receiver = new BroadcastReceiver() { @Override//from www . j a va2 s . c o m public void onReceive(Context context, Intent i) { int state = i.getIntExtra("state", Engine.INIT_SUCCESS); switch (state) { case Engine.GPS_ENABLED: case Engine.GPS_DISABLED: case Engine.LOCATION_PERMISSION_GRANTED: case Engine.LOCATION_PERMISSION_DENIED: case Engine.POWER_SAVE_MODE_DISABLED: case Engine.POWER_SAVE_MODE_ENABLED: case Engine.SDK_UP_TO_DATE: case Engine.SDK_UPDATE_AVAILABLE: case Engine.SDK_UPDATE_MANDATORY: { setAlerts(); break; } default: break; } setAlerts(); } }; mgr.registerReceiver(receiver, new IntentFilter(Engine.ACTION_LIFECYCLE)); }
From source file:com.bt.download.android.gui.activities.MainActivity.java
private void registerMainBroadcastReceiver() { mainBroadcastReceiver = new BroadcastReceiver() { @Override//from ww w .j ava 2 s .co m public void onReceive(Context context, Intent intent) { if (Constants.ACTION_NOTIFY_SDCARD_MOUNTED.equals(intent.getAction())) { onNotifySdCardMounted(); } } }; IntentFilter bf = new IntentFilter(Constants.ACTION_NOTIFY_SDCARD_MOUNTED); registerReceiver(mainBroadcastReceiver, bf); }
From source file:be.brunoparmentier.wifikeyshare.ui.activities.WifiNetworkActivity.java
void initializeNfcStateChangeListener() { nfcStateChangeBroadcastReceiver = new BroadcastReceiver() { @Override/*from w w w . j a va 2s . c om*/ public void onReceive(Context context, Intent intent) { final String action = intent.getAction(); if (action.equals(NfcAdapter.ACTION_ADAPTER_STATE_CHANGED)) { final int state = intent.getIntExtra(NfcAdapter.EXTRA_ADAPTER_STATE, NfcAdapter.STATE_OFF); switch (state) { case NfcAdapter.STATE_OFF: case NfcAdapter.STATE_TURNING_OFF: onNfcDisabled(); break; case NfcAdapter.STATE_TURNING_ON: break; case NfcAdapter.STATE_ON: onNfcEnabled(); break; } } } }; }
From source file:com.ubuntuone.android.files.service.UpDownService.java
private void registerUploadCancelReceiver() { LocalBroadcastManager bm = LocalBroadcastManager.getInstance(this); uploadCancelReceiver = new BroadcastReceiver() { @Override//from w w w.java 2 s.com public void onReceive(Context context, Intent intent) { if (uploadCancelReceiver != null) { uploadCancelTrigger.onCancel(); } Uri uri = intent.getData(); if (uri == null) { // Cancel all uploads. uri = Uploads.CONTENT_URI; } TransferUtils.dequeue(contentResolver, uri); } }; IntentFilter filter = new IntentFilter(ACTION_CANCEL_UPLOAD); bm.registerReceiver(uploadCancelReceiver, filter); }
From source file:com.yangtsaosoftware.pebblemessenger.services.NotificationService.java
@Override public void onCreate() { super.onCreate(); loadPrefs();//ww w. ja v a 2s . c o m bindService(new Intent(this, MessageProcessingService.class), connToMessageProcess, Context.BIND_AUTO_CREATE); BroadcastReceiver br = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { loadPrefs(); } }; IntentFilter intentFilter = new IntentFilter(NotificationService.class.getName()); LocalBroadcastManager.getInstance(getApplicationContext()).registerReceiver(br, intentFilter); }
From source file:com.polyvi.xface.extension.messaging.XMessagingExt.java
/** * ??/* w w w . j a v a 2 s . c o m*/ * */ private void genSendSMSBroadreceiver() { if (null == mSendSMSBroadcastReceiver) { mSendSMSBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context arg0, Intent arg1) { // ? SMS_RESULT_STATUS status = SMS_RESULT_STATUS.NO_STATUS; switch (getResultCode()) { case Activity.RESULT_OK:// ??? status = SMS_RESULT_STATUS.SEND_SUCCESS; break; case SmsManager.RESULT_ERROR_GENERIC_FAILURE:// status = SMS_RESULT_STATUS.ERROR_GENERIC_FAILURE; break; case SmsManager.RESULT_ERROR_NO_SERVICE:// ? status = SMS_RESULT_STATUS.ERROR_NO_SERVICE; break; case SmsManager.RESULT_ERROR_NULL_PDU:// PDU?? status = SMS_RESULT_STATUS.ERROR_NULL_PDU; break; case SmsManager.RESULT_ERROR_RADIO_OFF:// status = SMS_RESULT_STATUS.ERROR_RADIO_OFF; break; } resolveSMSSendResult(status); } }; } }