List of usage examples for android.content BroadcastReceiver BroadcastReceiver
public BroadcastReceiver()
From source file:com.numenta.taurus.chart.AbstractAnomalyChartFragment.java
public AbstractAnomalyChartFragment() { super();/*from w ww. jav a 2 s. c o m*/ _selectedTimestamp = -1; // Listen to InstanceData changes _instanceDataChangedReceiver = new BroadcastReceiver() { @Override public void onReceive(final Context context, final Intent intent) { update(); } }; // Listen to Annotations changes _annotationChangedReceiver = new BroadcastReceiver() { @Override public void onReceive(final Context context, final Intent intent) { update(); } }; }
From source file:eu.power_switch.gui.fragment.configure_geofence.ConfigureGeofenceDialogPage4SummaryFragment.java
@Nullable @Override// w w w . j a v a 2s . c o m public View onCreateView(final LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { rootView = inflater.inflate(R.layout.dialog_fragment_configure_geofence_page_4, container, false); // BroadcastReceiver to get notifications from background service if room data has changed broadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { if (LocalBroadcastConstants.INTENT_GEOFENCE_LOCATION_CHANGED.equals(intent.getAction())) { currentName = intent.getStringExtra("name"); double latitude = intent.getDoubleExtra("latitude", Geofence.INVALID_LAT); double longitude = intent.getDoubleExtra("longitude", Geofence.INVALID_LON); currentLocation = new LatLng(latitude, longitude); currentGeofenceRadius = intent.getDoubleExtra("geofenceRadius", -1); currentSnapshot = intent.getParcelableExtra("snapshot"); } else if (LocalBroadcastConstants.INTENT_GEOFENCE_ENTER_ACTIONS_CHANGED .equals(intent.getAction())) { currentEnterActions = (ArrayList<Action>) intent.getSerializableExtra("actions"); } else if (LocalBroadcastConstants.INTENT_GEOFENCE_EXIT_ACTIONS_CHANGED .equals(intent.getAction())) { currentExitActions = (ArrayList<Action>) intent.getSerializableExtra("actions"); } updateUi(); notifyConfigurationChanged(); } }; geofenceApiHandler = new GeofenceApiHandler(getActivity()); textViewName = (TextView) rootView.findViewById(R.id.textView_name); textViewLocation = (TextView) rootView.findViewById(R.id.textView_location); imageViewLocationSnapshot = (ImageView) rootView.findViewById(R.id.imageView_locationSnapshot); textViewGeofenceRadius = (TextView) rootView.findViewById(R.id.textView_geofence_radius); textViewEnterActions = (TextView) rootView.findViewById(R.id.textView_enter_actions); textViewExitActions = (TextView) rootView.findViewById(R.id.textView_exit_actions); Bundle args = getArguments(); if (args != null) { if (args.containsKey(ConfigureApartmentGeofenceDialog.APARTMENT_ID_KEY)) { apartmentId = args.getLong(ConfigureApartmentGeofenceDialog.APARTMENT_ID_KEY); } if (args.containsKey(ConfigureGeofenceDialog.GEOFENCE_ID_KEY)) { currentId = args.getLong(ConfigureGeofenceDialog.GEOFENCE_ID_KEY); initializeGeofenceData(currentId); } } updateUi(); return rootView; }
From source file:com.seamusdawkins.rest.MainActivity.java
public void checkConnection() { broadcastReceiver = new BroadcastReceiver() { @Override//from w w w.j ava 2 s. c om public void onReceive(Context context, Intent intent) { boolean conexao = AndroidUtils.thereConnection(context); if (conexao) { broadcast = true; mountUrl(); progressBar.setVisibility(View.VISIBLE); } else { ultimoEstadoConectado = conexao; } } }; }
From source file:com.liferay.alerts.activity.SignInActivity.java
private void _registerBroadcastReceiver() { IntentFilter filter = new IntentFilter(); filter.addAction(ACTION_FINISH);/*from w w w . j a va 2 s . c o m*/ _receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String action = intent.getAction(); if (ACTION_FINISH.equals(action)) { startActivity(new Intent(context, MainActivity.class)); finish(); } } }; _getBroadcastManager().registerReceiver(_receiver, filter); }
From source file:com.groksolutions.grok.mobile.chart.AbstractAnomalyChartFragment.java
public AbstractAnomalyChartFragment() { super();//from w w w . j a v a2 s . com _selectedTimestamp = -1; // Listen to MetricData changes _metricDataChangedReceiver = new BroadcastReceiver() { @Override public void onReceive(final Context context, final Intent intent) { update(); } }; // Listen to Annotations changes _annotationChangedReceiver = new BroadcastReceiver() { @Override public void onReceive(final Context context, final Intent intent) { update(); } }; }
From source file:com.oldster.swiftmovedriver.fragment.EditCarFragment.java
@SuppressWarnings("UnusedParameters") private void initInstances(View rootView, Bundle savedInstanceState) { // Init 'View' instance(s) with rootView.findViewById here mRegistrationBroadcastReceiver = new BroadcastReceiver() { public String toName; public String frName; public String distance; public String price; public String jid; public String status; public JSONObject data; public String payload; public String message; public String title; @Override/*from w w w .ja v a 2s.c o m*/ public void onReceive(Context context, Intent intent) { if (intent.getAction().equals(Config.PUSH_NOTIFICATION)) { try { title = intent.getStringExtra("title"); //check message = intent.getStringExtra("message");//check payload = intent.getStringExtra("payload");//check data = new JSONObject(payload);//check status = data.getString("status");//check if (status.equals("new_job")) { jid = data.getString("jid"); price = data.getString("price"); distance = data.getString("distance"); frName = data.getString("fr_name"); toName = data.getString("to_name"); } if (status.equals("cancel_job")) { } } catch (JSONException e) { Log.e(TAG, "Json Exception: " + e.getMessage()); } catch (Exception e) { Log.e(TAG, "Exception: " + e.getMessage()); } //Handle Code Here!! if (status.equals("new_job")) { new AlertDialog.Builder(getActivity()).setTitle(title) .setIcon(ContextCompat.getDrawable(getActivity(), R.drawable.ic_advertising)) .setMessage("? : #000" + jid + "\n" + " : " + frName + "\n" + " : " + toName + "\n" + "? : " + price + "\n" + " : " + distance) .setPositiveButton("", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { Intent intent = new Intent(getActivity(), DetailJobActivity.class); intent.putExtra("jid", jid); startActivity(intent); getActivity().overridePendingTransition(R.anim.from_right, R.anim.to_left); } }) .setNegativeButton("", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.dismiss(); } }) .show(); } else if (status.equals("cancel_job")) { new AlertDialog.Builder(getActivity()).setTitle(title) .setIcon(ContextCompat.getDrawable(getActivity(), R.drawable.ic_advertising)) .setMessage(message) .setPositiveButton("", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { dialogInterface.dismiss(); } }).show(); } } } }; if (((AppCompatActivity) getActivity()).getSupportActionBar() != null) { ((AppCompatActivity) getActivity()).getSupportActionBar() .setTitle("?"); } progressDialog = new ProgressDialog(getContext()); switch (driver.getDriverDetailType()) { case "Pickup": typeCarThai = "?"; break; case "Truck": typeCarThai = "?"; break; case "EcoCar": typeCarThai = " 5 "; break; } loadDataCarDriver(); mBind.btnSave.setOnClickListener(this); }
From source file:com.rerum.beans.StorageActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_storage); // Initialize Firebase Auth mAuth = FirebaseAuth.getInstance();//from ww w . j a v a 2 s . co m // Initialize Firebase Storage Ref // [START get_storage_ref] mStorageRef = FirebaseStorage.getInstance().getReference(); // [END get_storage_ref] // Click listeners findViewById(R.id.button_camera).setOnClickListener(this); findViewById(R.id.button_sign_in).setOnClickListener(this); findViewById(R.id.button_download).setOnClickListener(this); // Restore instance state if (savedInstanceState != null) { mFileUri = savedInstanceState.getParcelable(KEY_FILE_URI); mDownloadUrl = savedInstanceState.getParcelable(KEY_DOWNLOAD_URL); } // Download receiver mDownloadReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { Log.d(TAG, "downloadReceiver:onReceive:" + intent); hideProgressDialog(); if (MyDownloadService.ACTION_COMPLETED.equals(intent.getAction())) { String path = intent.getStringExtra(MyDownloadService.EXTRA_DOWNLOAD_PATH); long numBytes = intent.getLongExtra(MyDownloadService.EXTRA_BYTES_DOWNLOADED, 0); // Alert success showMessageDialog(getString(R.string.success), String.format(Locale.getDefault(), "%d bytes downloaded from %s", numBytes, path)); } if (MyDownloadService.ACTION_ERROR.equals(intent.getAction())) { String path = intent.getStringExtra(MyDownloadService.EXTRA_DOWNLOAD_PATH); // Alert failure showMessageDialog("Error", String.format(Locale.getDefault(), "Failed to download from %s", path)); } } }; }
From source file:com.measurence.sdk.android.demo.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_demo); if (savedInstanceState == null) { getSupportFragmentManager().beginTransaction().add(R.id.container, new NotificationsFragment()) .commit();//from ww w . j a v a 2 s . c o m } checkRegistration(); subscriptionResultBroadcastReceiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { String subscriptionResultMessage = intent .getStringExtra(MeasurenceApiSubscriptionService.SUBSCRIPTION_RESULT_INTENT_MESSAGE); displaySubscriptionResultMessage(subscriptionResultMessage); } }; if (presenceNotificationsListAdapter == null) { presenceNotificationsListAdapter = new ArrayAdapter<PresenceNotification>(this, R.layout.list_item_notification, R.id.list_item_notification_view, new ArrayList<PresenceNotification>()) { DateFormat dateFormat = DateFormat.getDateTimeInstance(); private void setText(View root, int id, String text) { TextView textView = (TextView) root.findViewById(id); textView.setText(text); } @Override public View getView(int position, View convertView, ViewGroup parent) { LayoutInflater inflater = (LayoutInflater) getContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); View itemView = inflater.inflate(R.layout.list_item_notification, null); PresenceNotification notification = getItem(position); PresenceSessionUpdate item = notification.presenceSessionUpdate; String now = dateFormat.format(notification.received); setText(itemView, R.id.list_item_notification_date, now); StringBuilder sb = new StringBuilder(); for (UserIdentity userid : item.getUserIdentities()) { sb.append(userid.getId()).append(" "); } setText(itemView, R.id.list_item_notification_userid, sb.toString()); setText(itemView, R.id.list_item_notification_storeid, item.getStoreKey()); setText(itemView, R.id.list_item_notification_new_user, getString(item.getIsNewVisitorInStore().booleanValue() ? R.string.yes : R.string.no)); setText(itemView, R.id.list_item_notification_status, item.getStatus()); setText(itemView, R.id.list_item_notification_session_start, dateFormat.format(item.getInterval().getStart())); setText(itemView, R.id.list_item_notification_session_end, dateFormat.format(item.getInterval().getEnd())); setText(itemView, R.id.list_item_notification_session_UUID, item.getUpdateUUID()); return itemView; } }; BroadcastReceiver broadcastReceiver = new BroadcastReceiver() { private void displaySessionUpdate(PresenceSessionUpdate presenceSessionUpdate) { PresenceNotification notification = new PresenceNotification(); notification.presenceSessionUpdate = presenceSessionUpdate; notification.received = new Date(); presenceNotificationsListAdapter.insert(notification, 0); Log.i(LOG_TAG, "displaying session update|" + presenceSessionUpdate); } @Override public void onReceive(Context context, Intent intent) { String presenceSessionUpdateJson = intent.getStringExtra( PresenceSessionUpdatesNotificationService.SESSION_UPDATE_JSON_PARAMETER); displaySessionUpdate(PresenceSessionUpdate.fromJson(presenceSessionUpdateJson)); } }; LocalBroadcastManager.getInstance(this).registerReceiver((broadcastReceiver), new IntentFilter(PresenceSessionUpdatesNotificationService.SESSION_UPDATE_INTENT_ID)); } }
From source file:com.example.testplayer.NetworkManager.java
/** * Sets the context of the Command. This can then be used to do things like * get file paths associated with the Activity. * * @param cordova The context of the main Activity. * @param webView The CordovaWebView Cordova is running in. */// w w w .j a v a 2 s. c om public void initialize(CordovaInterface cordova, CordovaWebView webView) { super.initialize(cordova, webView); this.sockMan = (ConnectivityManager) cordova.getActivity().getSystemService(Context.CONNECTIVITY_SERVICE); this.connectionCallbackContext = null; // We need to listen to connectivity events to update navigator.connection IntentFilter intentFilter = new IntentFilter(); intentFilter.addAction(ConnectivityManager.CONNECTIVITY_ACTION); if (this.receiver == null) { this.receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { // (The null check is for the ARM Emulator, please use Intel Emulator for better results) if (NetworkManager.this.webView != null) updateConnectionInfo(sockMan.getActiveNetworkInfo()); } }; webView.getContext().registerReceiver(this.receiver, intentFilter); } }
From source file:com.polyvi.xface.extension.XMessagingExt.java
private void genMsgReceiveBroadcastReceive() { if (null == mMsgReceiveBroadcaseReveiver) { mMsgReceiveBroadcaseReveiver = new BroadcastReceiver() { @Override// w w w.j av a2 s. co m public void onReceive(Context context, Intent intent) { if (INTENT_ACTION.equals(intent.getAction())) { Bundle bundle = intent.getExtras(); if (null != bundle) { // pdus?? Object[] pdus = (Object[]) bundle.get("pdus"); // SmsMessage[] msgs = new SmsMessage[pdus.length]; for (int i = 0; i < pdus.length; i++) { // ???pdu?,? msgs[i] = SmsMessage.createFromPdu((byte[]) pdus[i]); } JSONArray receivedMsgs = buildSmsList(msgs); XEvent evt = XEvent.createEvent(XEventType.MSG_RECEIVED, receivedMsgs.toString()); XSystemEventCenter.getInstance().sendEventAsync(evt); } } } }; } }