Advertisement
eql5121

DeviceSetupActivityFragment.java

Feb 17th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.17 KB | None | 0 0
  1.         // place under public void onViewCreated(View view, Bundle savedInstanceState)
  2.  
  3.         view.findViewById(R.id.humidity_start).setOnClickListener(v -> {
  4.             humidity = metawear.getModule(HumidityBme280.class);
  5.             Log.i("Humidity", "Humidity sensor started.");
  6.             humidity.setOversampling(HumidityBme280.OversamplingMode.SETTING_16X);
  7.             humidity.value().addRouteAsync(new RouteBuilder() {
  8.                 @Override
  9.                 public void configure(RouteComponent source) {
  10.                     source.stream(new Subscriber() {
  11.                         @Override
  12.                         public void apply(Data data, Object... env) {
  13.                             Log.i("MainActivity", "Humidity = " + data.value(Float.class));
  14.                         }
  15.                     });
  16.                     }
  17.                 }).continueWith(new Continuation<Route, Void>(){
  18.                         @Override
  19.                         public Void then(Task<Route> task) throws Exception {
  20.                             humidity.value().read();
  21.                             return null;
  22.                         }
  23.                 });
  24.  
  25.         });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement