1
我有2班GLLayer
和GLCamTest
。我試圖運行位於GLCamTest
的方法...我如何在這裏實現一個處理程序?
public Bitmap extractimage(int pos){
LocationData tweets;
tweets = new LocationData(this);
SQLiteDatabase db = tweets.getWritableDatabase();
//select the data
String query = "SELECT * FROM tweets;";
Cursor mcursor = db.rawQuery(query, null);
//Move to Position specified.
mcursor.moveToPosition(pos);
//get it as a ByteArray
byte[] imageByteArray=mcursor.getBlob(7);
//the cursor is not needed anymore
mcursor.close();
//convert it back to an image
ByteArrayInputStream imageStream = new ByteArrayInputStream(imageByteArray);
Bitmap theImage = BitmapFactory.decodeStream(imageStream);
return theImage;
}
我期待從GLLayer
,但是從我的理解,我需要一個處理器上的線程來運行..
public void run() {
GLCamTest cam = new GLCamTest();
image = cam.extractimage(q);
}
我從public void onDrawFrame(GL10 gl) {
開始線程我的問題是我將如何實現上述處理程序?我讀過http://developer.android.com/reference/android/os/Handler.html,但我仍然不太明白我將如何實施它。有人能幫助我嗎?