Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

java - Native functions throw UnsatisfiedLinkError in custom view, despite working in main activity -


for reason can call native functions main activity , not custom views i've created. here example file (i followed tutorial, renamed classes http://mindtherobot.com/blog/452/android-beginners-ndk-setup-step-by-step/)

see usage of native function "getnewstring".

package com.example.native;  import android.app.activity; import android.app.alertdialog; import android.content.context; import android.graphics.bitmap; import android.graphics.canvas; import android.os.bundle; import android.view.view;  public class nativetestactivity extends activity {        static     {         system.loadlibrary("nativetest");     }      private native string getnewstring();      @override public void oncreate(bundle savedinstancestate)     {         super.oncreate(savedinstancestate);                 this.setcontentview(new bitmapview(this));          string hello = getnewstring(); // line works fine         new alertdialog.builder(this).setmessage(hello).show();     } }  class bitmapview extends view {     static     {         system.loadlibrary("nativetest");     }      private native string getnewstring();      public bitmapview(context context)     {         super(context);          string hello = getnewstring(); // line throws unsatisfiedlinkerror         new alertdialog.builder(this.getcontext()).setmessage(hello).show();     } } 

how can call native functions in custom views?

i've built application android 2.2 app. i'm running application on htc desire. have latest sdk (9) , latest ndk (r5).

your problem trying call native function class dont belongs to.

you defined following jni function in c file:

jstring java_com_example_native_nativetestactivity_getnewstring()

this states native function when loaded bind method declared native in nativetestactivity class. when try call view class doesn't find function bind to.

in case following function (which of course not exist in .so):

jstring java_com_example_native_bitmapview_getnewstring()

if still want able call same function different classes can declare in container class can accessed class want.

eg:

java code:

package com.example.native; public class nativehelper {      public native string getnewstring();      static      {          system.loadlibrary("nativetest");      } } 

c code:

jstring java_com_example_native_nativehelper_getnewstring(jnienv* env, jobject javathis) {      return (*env)->newstringutf(env, "hello native code!"); } 

Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -