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

  • Home
  • SEARCH
  • 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 7994771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T14:12:55+00:00 2026-06-04T14:12:55+00:00

in my android application it does not seem to let me use the accelerometer.

  • 0

in my android application it does not seem to let me use the accelerometer. when i call it in a statement the application crashes. the statement that seems to be causing the crash is:

SensorManager sensorManager = (SensorManager)getSystemService(Context.SENSOR_SERVICE);

The application is simple as is only calls the accelerometer and runs when this statement is absent, the above statment is called before the onCreate method and the log cat is below

05-24 20:08:46.990: E/AndroidRuntime(1149): FATAL EXCEPTION: main
05-24 20:08:46.990: E/AndroidRuntime(1149): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.b00348312.workout/com.b00348312.workout.WorkoutAppActivity}: java.lang.IllegalStateException: System services not available to Activities before onCreate()
05-24 20:08:46.990: E/AndroidRuntime(1149):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2585)
05-24 20:08:46.990: E/AndroidRuntime(1149):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
05-24 20:08:46.990: E/AndroidRuntime(1149):     at android.app.ActivityThread.access$2300(ActivityThread.java:125)
05-24 20:08:46.990: E/AndroidRuntime(1149):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
05-24 20:08:46.990: E/AndroidRuntime(1149):     at android.os.Handler.dispatchMessage(Handler.java:99)
05-24 20:08:46.990: E/AndroidRuntime(1149):     at android.os.Looper.loop(Looper.java:123)
05-24 20:08:46.990: E/AndroidRuntime(1149):     at android.app.ActivityThread.main(ActivityThread.java:4627)
05-24 20:08:46.990: E/AndroidRuntime(1149):     at java.lang.reflect.Method.invokeNative(Native Method) 
05-24 20:08:46.990: E/AndroidRuntime(1149):     at java.lang.reflect.Method.invoke(Method.java:521)
05-24 20:08:46.990: E/AndroidRuntime(1149):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-24 20:08:46.990: E/AndroidRuntime(1149):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-24 20:08:46.990: E/AndroidRuntime(1149):     at dalvik.system.NativeStart.main(Native Method)
05-24 20:08:46.990: E/AndroidRuntime(1149): Caused by: java.lang.IllegalStateException: System services not available to Activities before onCreate()
05-24 20:08:46.990: E/AndroidRuntime(1149):     at android.app.Activity.getSystemService(Activity.java:3526)
05-24 20:08:46.990: E/AndroidRuntime(1149):     at com.b00348312.workout.WorkoutAppActivity.<init>(WorkoutAppActivity.java:25)   
05-24 20:08:46.990: E/AndroidRuntime(1149):     at java.lang.Class.newInstanceImpl(Native Method)
05-24 20:08:46.990: E/AndroidRuntime(1149):     at java.lang.Class.newInstance(Class.java:1429)
05-24 20:08:46.990: E/AndroidRuntime(1149):     at android.app.Instrumentation.newActivity(Instrumentation.java:1021) 
05-24 20:08:46.990: E/AndroidRuntime(1149):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
05-24 20:08:46.990: E/AndroidRuntime(1149):     ... 11 more

from the logcat i cannot figure out the cause of this problem when this statement worked in a different programme.

  • 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-04T14:12:56+00:00Added an answer on June 4, 2026 at 2:12 pm

    Thats a double negative? lol Cut the code where ure calling the system service and paste inside your onCreate

     public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.main);
    
    //PLACE YOUR ACCEL CODE IN HERE       
    
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am developing a library for Android applications which does not use native code
I am working on Android application that parses a website but I can't seem
I'm creating an android application. It compiles well and eclipse does not spot any
I'm creating my first android application but it does not start at all. In
After android installs an application from the Marketplace, does it keep the .apk file?
We developed a placeholder application to ship pre-installed on Android devices. All it does
Our android application is getting fairly big and we would like to use functional
I am trying to write a very simple Android application that checks the signal
I am working on an Android application that is aimed at Tablets only. The
I have developed an application that does require to do constant network activity. This

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.