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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:24:50+00:00 2026-05-23T01:24:50+00:00

I got the following code inside my templateApp.java: package com.android.templateApp; import android.app.Activity; import android.os.Bundle;

  • 0

I got the following code inside my templateApp.java:

    package com.android.templateApp;

    import android.app.Activity;
    import android.os.Bundle;
    import android.hardware.Sensor;
    import android.hardware.SensorEvent;
    import android.hardware.SensorEventListener;
    import android.hardware.SensorManager;

    public class templateApp extends Activity implements SensorEventListener
    {  
        GL2View mView;

        SensorManager mSensorManager;

        @Override protected void onCreate(Bundle icicle)
        {    
            super.onCreate( icicle );

            mSensorManager = ( SensorManager ) getSystemService( SENSOR_SERVICE );

            mView = new GL2View( getApplication() );

            mSensorManager.registerListener( this, 
                                             mSensorManager.getDefaultSensor( SensorManager.SENSOR_ACCELEROMETER ), 
                                             SensorManager.SENSOR_DELAY_GAME );

            setContentView( mView );
        }   

        @Override protected void onResume()
        {
            super.onResume();

            mView.onResume();
        }    


        public static native void Accelerometer( float x, float y, float z );

        public void onSensorChanged( SensorEvent event )
        {
            float x = event.values[ SensorManager.DATA_X ],
                  y = event.values[ SensorManager.DATA_Y ],
                  z = event.values[ SensorManager.DATA_Z ];

            // ALWAYS CRASH HERE!!!!
            Accelerometer( x, y, z );
        }

        public void onAccuracyChanged( Sensor sensor, int arg1 ) {}
    }

And inside my templateApp.cpp I got the following to bridge the Accelerometer function:

    extern "C"
    {
        JNIEXPORT void JNICALL Java_com_android_templateApp_GL2View_Init( JNIEnv *env, jobject obj,  jint width, jint height );


        JNIEXPORT void JNICALL Java_com_android_templateApp_templateApp_Accelerometer( JNIEnv *env, jfloat x, jfloat y, jfloat z );
    };

    JNIEXPORT void JNICALL Java_com_android_templateApp_GL2View_Init( JNIEnv *env, jobject obj,  jint width, jint height )
    { Init( width, height); }

    JNIEXPORT void JNICALL Java_com_android_templateApp_templateApp_Accelerometer( JNIEnv *env, jfloat x, jfloat y, jfloat z )
    { Accelerometer( x, y,z ); }

When I pass my mouse over in eclipse it show that the call belong to
com.android.templateApp.templateApp.Accelerometer, which is exactly what I declare, however it always crash reporting an UnsatisfiedLinkError.

I tried every combination (assuming that my native definition is wrong) but it keep crashing at the Accelerometer call inside the java code… Weird thing is that my init function that is inside my GL2View.java work flawless. Is there anything that prevent me to call a native API from the main file that extends Activity? Cuz the sensor work, I print the value its the native call that crash and I don’t know why.

Tks in advance!

  • 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-23T01:24:50+00:00Added an answer on May 23, 2026 at 1:24 am

    Have you initiated your native code? This is mine, it located in the class with native methods exposed.

    static {
        Log.v("NativeCodeWrapper.java", "Loading native libraries");
        System.loadLibrary("NameOfNativeModuleAsDefinedInAndroidDotMk");
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have got the following code in a file called test.java which is located
I've got a following code snippet: def isolation_level(level): def decorator(fn): def recur(level, *args, **kwargs):
I've got the following code: <div onclick=alert('div event'); style=cursor:pointer> some text <a href=asd.php id=link>click</a>
I'm experimenting with pthread library and I've got the following piece of code: for
Tried the following code : #include<stdio.h> int main() { int *p,*q; p = (int
I've got a bunch of stateful functions inside a State monad. At one point
I have a SurfaceListBox inside an ScatterViewItem. It feets ok, but the thing is
This question has also been asked at Problems with MediaRecorder class setting audio source
Hey all, I'm very new to mongodb, mongoose and node.js. I would like to
Before running integration tests I need to setup database. This include generating SQL-scheme (based

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.