Created
April 16, 2012 14:59
-
-
Save kidfolk/2399280 to your computer and use it in GitHub Desktop.
handler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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