Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6899479
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:25:36+00:00 2026-05-27T07:25:36+00:00

For example. I´m working with accelerometer and i want values x,y,z in another class

  • 0

For example. I´m working with accelerometer and i want values x,y,z in another class ThreatForLoopA.

@Override
public void onSensorChanged(int sensor, float[] values) {
    // TODO Auto-generated method stub

    x = values[0];
    y = values[1];
    z = values[2];

    ThreadForLoopA threadA = new ThreadForLoopA();

    if (sensor == SensorManager.SENSOR_ACCELEROMETER) {
        long curTime = System.currentTimeMillis();

    threadA.start();

This is example of class ThreatForLoopA:

public class ThreadForLoopA extends Thread{

TextView xacc = null;
TextView yacc = null;
TextView zacc = null;

float[][] p= new float[5][3];
private long lastUpdate = -1;
public float x,y,z;
int row = 0;

@Override
public void run() {
    // TODO Auto-generated method stub

    long curTime = System.currentTimeMillis();

    if (lastUpdate == -1 || (curTime - lastUpdate) > 2000) {
        lastUpdate = curTime;

            for (int column = 0; column < 3; column++) {
                if (column == 0) {
                    p[row][column] = x;
                    //xacc.setText("Os X: " + p[row][column]);
                }
                if (column == 1) {
                    p[row][column] = y;
                    //yacc.setText("Os X: " + p[row][column]);
                }
                if (column == 2) {
                    p[row][column] = z;
                    //zacc.setText("Os X: " + p[row][column]);
                }}
                if (row == 0) {
                    xacc.setText("Os X: " + p[row][0] + " " + p[row][1] +" " + p[row][2]);
                }

How can i get accelerometer values from onSensorChanged to class ThreatForLoopA?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T07:25:37+00:00Added an answer on May 27, 2026 at 7:25 am

    Well, pass them in the constructor:

    ThreadForLoopA threadA = new ThreadForLoopA(x, y, z);
    

    …

    public ThreadForLoopA(float x, float y, float z) {
        this.x = x;
        this.y = y;
        this.z = z;
    }
    

    and make all these fields private.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For example if I'm working on Visual Studio 2008, I want the values devenv
I'm working with Apple's Accelerometer Graph Example: http://developer.apple.com/library/ios/#samplecode/AccelerometerGraph/Introduction/Intro.html I'm pushing 2 Graph Views onto
Trying to get this example working from http://www.munna.shatkotha.com/blog/post/2008/10/26/Light-box-effect-with-WPF.aspx However, I can't seem to get
anyone has a working example of a TTThumbsViewController used with files included in the
Can someone provide a working example in which stored procedure returns a recordset and
Does anyone have a working example of a video player built using Qt phonon?
Does anybody have an example of working with database using Visual C++ and OLEDB?
Does anyone has the code to a full working example of slartoolkit ( http://slartoolkit.codeplex.com/
I need to calculate date (year, month, day) which is (for example) 18 working
Does anybody know of a working code example of the sum-product algorithm for (loopy)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.