• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • paul wheaton
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Tim Holloway
  • Carey Brown
  • salvin francis

How to pass received bluetooth data as an input to a static class

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a code that I've been trying to solve for weeks. I'm actually a beginner so what I usually do is find solutions on java forums. But then, this one I'm really having a hard time to solve, so it would be of really great help for me if any of you could help solve this problem.

I wanted to create an android application (using android studio) that could monitor sensor readings through bluetooth. I've already managed to create an activity for my bluetooth connection. Now what I wanted to do is to pass my bluetooth data to another activity where I could apply some mathematical equations and processing methods. About the second activity (where I want to pass the data) I already have one. I got the code  from another study but then its just a snippet of the process that I want. So I'm left to understand the rest.

Here is the code:





My problem
I need to pass my received reading/signal to this activity and then use that data as an input to this. It should be the ecgSignal. There are two requesting for a variable: (double[] ecgSignals under computelfhfRatio and double ecgSignal under computeWindow). I think I could pass my received data/signal to either one of this since this code uses a return and the variables are shared.

From what I've studied so far, this is a static class that only accepts a static variable. I've tried several methods to pass my received bluetooth data to this code such as the

intent.putExtra , getIntent, calling the Class.variablename (but this gives out error), creating a separate class that contains this code and an intent that sends the bluetooth data

But then this code being static really gives out a lot of error. Can any of you guyz help me? I could really use some help.
 
Saloon Keeper
Posts: 5765
146
Android Mac OS X Firefox Browser VI Editor Tomcat Server Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't really follow all that you wrote, but I note that a lot of the methods are private - why is that? Static methods are usually public (which would allow you to call them from anywhere). If that doesn't help, post the errors you're getting.
 
Klarisk Cersul
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First of all, thank you for your suggestion.
I followed what you said and yes I was able to access the rest of the classes in my bluetooth activity.
But what I really wanted to know is how I would be able to use my received bluetooth data as an input to this class
public static double computeWindowed(double ecgSignal, double hWindow) {


This is my bluetooth handler. This is where I need to call the class where my data goes to.



Note
That **** part is the class.variableName where I wanted to pass my bluetooth data as an input. And as you can see the data would be the ecgSignal.


Now I wanted to pass that ecgSignal in the code below. I want it to be the input for this part. Just the double ecgSignal





 
Master Rancher
Posts: 4208
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, that method requires two values, so you can't just pass it the ecgSignal value.
You need something to pass for the hWindow parameter as well.

What that is I have no idea, but that's what the method is expecting.
 
Klarisk Cersul
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm sorry about that it's actually this double[] ecgSignals



In my handler state, when I try to call the class.varName which is LFHFCalculator.computeLFHFRatio
this happens


https://imgur.com/gallery/fIU0AAM

 
Dave Tolls
Master Rancher
Posts: 4208
47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I can't see images from here.
Is it an exception?
If so copy and paste it into the thread.
 
Oh the stink of it! Smell my tiny ad!
Enterprise-grade Excel API for Java
https://products.aspose.com/cells/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!