Android Service类中调用NDK编译的库的问题

Android Service类中调用NDK编译的库的问题

问题描述:

现碰到的问题如下: 在Java层写了一个类代码如下:

public class MeiaPush {
        public native int meia_push_init ();
        public native int meia_push_set_client_info (String cid, String pwd, String type, String token);
        public native int meia_push_get_alarmlist (Object param, int count);
        public native int meia_push_exit ();
         
        public int MeiaPushInit ()
        {
            Log.e ("Yan", "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
            meia_push_init ();
            return meia_push_set_client_info ("00000000001", "123456", "android", "yan_yan");
        }
}

JNI层也实现了。

在其它类中调用MeiaPushInit 这个函数没有问题,
但是在Service类中调用就会出现“java.lang.unsatisfiedlinkerror native method not found”
请问 为什么会出现这个问题, 如何解决。 Service类中和其它类调用JNI函数有什么区别么?
谢谢!

这是帖子地址:Android Service类中调用NDK编译的库的问题

缺了
static{
    System.loadLibrary("MeiaPush ");
}
吧

MeiaPush不是Service类。
我记忆中,JNI里面需要一个参数是Context类。MeiaPush对象不是Context的子类对象。

问题描述如下:
我在service类中开了一个线程, 然后在线程中写了如下代码:

 intent = new Intent (getBaseContext (), MeiaAlarmDetail.class); 
Bundle bundle = new Bundle();  
bundle.putString("DevID", alarm_info.DevID);
intent.putExtras (bundle);

但是在MeiaAlarmDetail.class这个类中, 去调用getExtras, 返回值却是null。