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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T04:33:07+00:00 2026-06-04T04:33:07+00:00

I cant find what is wrong here in this code. I am trying to

  • 0

I cant find what is wrong here in this code. I am trying to get acceletometer data, but when i try to run it on device it comes out with a message, that process has been shut down.

public class SensorActivity extends Activity implements SensorEventListener {   
SensorManager sm;
Sensor sensor ;
TextView yViewA = null;
TextView zViewA = null;
TextView xViewO = null;
TextView yViewO = null;
TextView zViewO = null;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);


 sm = (SensorManager)getSystemService(SENSOR_SERVICE);
 sensor = sm.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
 xViewA = (TextView) findViewById(R.id.xbox);
 yViewA = (TextView) findViewById(R.id.ybox);
 zViewA = (TextView) findViewById(R.id.zbox);
 xViewO = (TextView) findViewById(R.id.xboxo);
 yViewO = (TextView) findViewById(R.id.yboxo);
 zViewO = (TextView) findViewById(R.id.zboxo);


}    

@Override
protected void onResume() {
    super.onResume();
    sm.registerListener(this, sensor, SensorManager.SENSOR_DELAY_NORMAL);
}

@Override
protected void onStop() {
    sm.unregisterListener(this);
    super.onStop();
}

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

}

public void onSensorChanged(SensorEvent event) {
    // TODO Auto-generated method stub  

    xViewO.setText("Orientation X: " + event.values[0]);
    yViewO.setText("Orientation Y: " + event.values[1]);
    zViewO.setText("Orientation Z: " + event.values[2]);

} 

UPD:

05-18 19:42:17.570: E/AndroidRuntime(14875): android.app.SuperNotCalledException: Activity {daler.sensor/daler.sensor.SensorActivity} did not call through to super.onCreate()

05-18 19:42:17.570: E/AndroidRuntime(14875):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1933)

05-18 19:42:17.570: E/AndroidRuntime(14875):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)

05-18 19:42:17.570: E/AndroidRuntime(14875):    at android.app.ActivityThread.access$600(ActivityThread.java:127)

05-18 19:42:17.570: E/AndroidRuntime(14875):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158)

05-18 19:42:17.570: E/AndroidRuntime(14875):    at android.os.Handler.dispatchMessage(Handler.java:99)

05-18 19:42:17.570: E/AndroidRuntime(14875):    at android.os.Looper.loop(Looper.java:137)

05-18 19:42:17.570: E/AndroidRuntime(14875):    at android.app.ActivityThread.main(ActivityThread.java:4441)

05-18 19:42:17.570: E/AndroidRuntime(14875):    at java.lang.reflect.Method.invokeNative(Native Method)

UPD2: Code is updated, still facing problem.
UPD3:Log cat updated

UPD4: I updated the code, now it works. Maybe someone will need it. Thanks.

  • 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-04T04:33:08+00:00Added an answer on June 4, 2026 at 4:33 am

    You can’t put findViewById(R.id.xbox); in your class body. It should go to onCreate() after setContentView().

    The problem is on line 18 of your code (according to logcat). It’s probably this one:

    Sensor sensor = sm.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);

    Because you write:
    SensorManager sm;
    so the sensor manager is null so you can’t use it in sm.getDefaultSensor().

    See this link to find out how to initalize sensor manager:

     public SensorActivity() {
         sm = (SensorManager)getSystemService(SENSOR_SERVICE);
         sensor = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just dont get it.. this happens here and there but I cant find
I cant find one way to get this value (comment) into json using javascript.
Been searching all over for this but cant find an answer so thought I
What's wrong with this set of code? I have errors and I can't find
I've been trying to troubleshoot this, but can't find a good function that will
Well, I don't know if I'm completely wrong, but I really can't find a
but cant find any information. Restricted on time. I have a Datagridview, 6 fields.
Dust me selectors is installed but cant find anyway of saving the css minus
similar questions have been asked before but I cant find an exact match to
Ive been searching for an answer for this and cant find one, although 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.