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 8873673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:31:25+00:00 2026-06-14T18:31:25+00:00

My code used to work on 2.2, and I was able to get the

  • 0

My code used to work on 2.2, and I was able to get the gyroscope data, but after the update to 2.3, it does not work anymore. I also tried on a galaxy player to make sure it’s not a hardware issue with my phone. It did not work on that one either. Any suggestions? Here’s the code:

    package my.acc;
    
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.FileOutputStream;
    import java.io.PrintWriter;
    
    import android.app.Activity;

    import android.hardware.Sensor;
    import android.hardware.SensorManager;
    import android.os.Bundle;
    import android.view.View;
    import android.view.View.OnClickListener;
    import android.widget.ArrayAdapter;
    import android.widget.EditText;
    import android.widget.Spinner;
    import android.widget.ToggleButton;
    
    public class myact extends Activity {
        
        private SensorManager mSensorManager;
        Sensor myAcc, myAcc2, myAcc3, myAcc4;
        MySensorListener listener, listener2,listener3, listener4;
        EditText mEdit;
    
    
        
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
            
            final Spinner spinner = (Spinner) findViewById(R.id.spinner);
            ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(
                    this, R.array.activity_array, android.R.layout.simple_spinner_item);
            adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
            spinner.setAdapter(adapter);
    
            
            // Set up the accelerometer reading
            mSensorManager = (SensorManager)getSystemService(SENSOR_SERVICE);
            myAcc = mSensorManager.getDefaultSensor(Sensor.TYPE_LINEAR_ACCELERATION);
            myAcc2 = mSensorManager.getDefaultSensor(Sensor.TYPE_GYROSCOPE);
            myAcc3 = mSensorManager.getDefaultSensor(Sensor.TYPE_ORIENTATION);
            myAcc4 = mSensorManager.getDefaultSensor(Sensor.TYPE_GRAVITY);
    
            final ToggleButton togglebutton = (ToggleButton) findViewById(R.id.togglebutton);
            mEdit   = (EditText)findViewById(R.id.entry);
    
            togglebutton.setOnClickListener(new OnClickListener() {
                PrintWriter mCurrentFile = null;
                PrintWriter mCurrentFile2 = null;
                PrintWriter mCurrentFile3 = null;
                PrintWriter mCurrentFile4 = null;
    
    
                public void onClick(View v) {
                    // Perform action on clicks
                    if (togglebutton.isChecked()) {

                        String strname = spinner.getSelectedItem().toString();
                        if (strname.equals("Select Activity")){
                            strname = mEdit.getText().toString();
                        }
                        String nameStr  = new String("/sdcard/" + strname + "acc" + ".csv");
                        String nameStr2 = new String("/sdcard/" + strname + "gyr" + ".csv");
                        String nameStr3 = new String("/sdcard/" + strname + "ori" + ".csv");
                        String nameStr4 = new String("/sdcard/" + strname + "gra" + ".csv");
    
                        File outputFile = new File(nameStr);
                        File outputFile2 = new File(nameStr2);
                        File outputFile3 = new File(nameStr3);
                        File outputFile4 = new File(nameStr4);
                        
                        try {
                            mCurrentFile = new PrintWriter(new FileOutputStream(outputFile));
                            mCurrentFile2 = new PrintWriter(new FileOutputStream(outputFile2));
                            mCurrentFile3 = new PrintWriter(new FileOutputStream(outputFile3));
                            mCurrentFile4 = new PrintWriter(new FileOutputStream(outputFile4));
    
                        } catch (FileNotFoundException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
    
                        mSensorManager.registerListener(listener = new MySensorListener(mCurrentFile), myAcc , SensorManager.SENSOR_DELAY_UI);
                        mSensorManager.registerListener(listener2 = new MySensorListener(mCurrentFile2), myAcc2 , SensorManager.SENSOR_DELAY_UI);
                        mSensorManager.registerListener(listener3 = new MySensorListener(mCurrentFile3), myAcc3 , SensorManager.SENSOR_DELAY_UI);
                        mSensorManager.registerListener(listener4 = new MySensorListener(mCurrentFile4), myAcc4 , SensorManager.SENSOR_DELAY_UI);
    
                        //mSensorManager.registerListener(listener, myAcc2 , SensorManager.SENSOR_DELAY_FASTEST);
    
                    } else {
                        

                        mSensorManager.unregisterListener(listener, myAcc);
                        mSensorManager.unregisterListener(listener2, myAcc2);
                        mSensorManager.unregisterListener(listener3, myAcc3);
                        mSensorManager.unregisterListener(listener4, myAcc4);
                        mCurrentFile.close();
                        mCurrentFile2.close();
                        mCurrentFile3.close();
                        mCurrentFile4.close();
                        

    
                        
                    }
                }
            });
        }
    }
package my.acc;

import java.io.PrintWriter;

import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;

public class MySensorListener implements SensorEventListener {

    String comma = new String(",");
  private PrintWriter mCurrentFile;
  
    public MySensorListener( PrintWriter mCurrentFile){
      //Creating a file to print the data into
       
      this.mCurrentFile = mCurrentFile;

    }

    
    public void onAccuracyChanged(Sensor sensor, int accuracy) {
            // TODO Auto-generated method stub

    }


    
    public void onSensorChanged(SensorEvent event) {
        
        StringBuffer buff = new StringBuffer();

        buff.append(String.valueOf(event.sensor.getName()));     
        buff.append(comma);


        buff.append(String.valueOf(event.timestamp));
        

        buff.append(comma);

          buff.append(String.valueOf(event.values[0]));
          buff.append(comma);
          buff.append(String.valueOf(event.values[1]));
          buff.append(comma);
          buff.append(String.valueOf(event.values[2]));

        mCurrentFile.println(buff.toString());
        mCurrentFile.flush();
        

    }


}

I even reported as a bug to google here is their response:

those aren’t Google devices, so you’ll have to talk to Samsung

  • 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-06-14T18:31:27+00:00Added an answer on June 14, 2026 at 6:31 pm

    Seems to be just a Samsung issue. Filing the issue with Google did not help; they referred me back to Samsung.

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

Sidebar

Related Questions

This piece of code used to work in MVC 1 but it does not
This code used to work but doesnt any more. i used a breakpoint, and
I swear the following code used to work, even in IE7 but now i
this code in my plugin used to work just fine: jQuery('#embedded_obj', context).get(0).getVersion(); and the
The following source code are used to implement product/consumer pattern, but they don't work
UPDATE I was able to get everything to work properly and I just wanted
This code used to work. Then, maybe I changed something, somewhere (or if I
...at least to me. This code used to work fine. I'm pretty sure nothing
I'm having a problem with some code that used to work in PHP 4.X
I used textmate to work with ruby code for over one year. Recently I

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.