Skip to content

Instantly share code, notes, and snippets.

@kidfolk
Created April 16, 2012 14:59
Show Gist options
  • Save kidfolk/2399280 to your computer and use it in GitHub Desktop.
Save kidfolk/2399280 to your computer and use it in GitHub Desktop.
handler
public class Test {
static{
System.loadLibrary("test");
}
public native int getStringLen(String str);
private CallBack callBack;
public void setCallBack(CallBack callBack){
this.callBack = callBack;
}
public interface CallBack{
public abstract void callback();
}
private Handler mHandler = new Handler(){
@Override
public void handleMessage(Message msg) {
Test.this.callBack.callback();
}
};
//call by c function
public void calledByC(int params){
mHandler.sendMessage(new Message());
}
}
public class TestActivity extends Activity implements CallBack{
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void callback() {
// TODO Auto-generated method stub
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment