它适用于genymotion,但在我的手机上失败(API层18):我启动了imagepicker 并尝试使用onActivityResult()获得答案。随着genymotion它正在被呼叫,但不是在我的手机上。某处肯定会发生崩溃
public void onEvent(SelectSectionImagesEvent event)
{
Intent intent = new Intent(getApplicationContext(), activity_story.class);
intent.setType("image/*");
intent.setAction(Intent.ACTION_GET_CONTENT);
waitForResult = true;
startActivityForResult(Intent.createChooser(intent, "Select Picture"), PICK_COVER);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode,resultCode, data);
Log.d("device test", "onActivityResult");
waitForResult = false;
if (resultCode != RESULT_OK) return;
if(requestCode == PICK_SECTION_ITEM)
{
// section befüllen
String path = MyApplication.getRealPathFromURI(MyApplication.getAppContext(), data.getData());
Log.d("selected File", path);
File file = new File(path);
Item item = new Item();
item.fileName = file.getName();
item.fillRow = true;
item.path = path;
ImageLoader.getInstance().loadImage("file://" + path, new SectionImagePickedLoadListener(sectionAddImage, item));
}
}
@Override
public void onPause()
{
super.onPause();
Log.d("device test", "onPause");
}
在genymotion中,logcat打印出以下内容:
>D/device test﹕ onPause
>W/EGL_genymotion﹕ eglSurfaceAttrib not implemented
>D/device test﹕ onActivityResult
这是在我的手机上制作的:
>D/device test﹕ onPause
>D/AbsListView﹕ unregisterIRListener() is called
>D/dalvikvm﹕ GC_FOR_ALLOC freed 22422K, 63% free 14229K/37812K, paused 54ms, total 54ms
>D/AbsListView﹕ Get MotionRecognitionManager
>D/AbsListView﹕ onVisibilityChanged() is called, visibility : 4
>D/AbsListView﹕ unregisterIRListener() is called
>D/AbsListView﹕ onVisibilityChanged() is called, visibility : 0
>D/AbsListView﹕ unregisterIRListener() is called
01-06 17:11:59.305 2889-2889/com.example.user.myApp I/Choreographer﹕ Skipped 50 frames! The application may be doing too much work on its >D/dalvikvm﹕ GC_FOR_ALLOC freed 46K, 59% free 15744K/37812K, paused 24ms, total 25ms
>D/AbsListView﹕ unregisterIRListener() is called
>D/AbsListView﹕ unregisterIRListener() is called
>D/AbsListView﹕ unregisterIRListener() is called
>D/AbsListView﹕ unregisterIRListener() is called
>D/AbsListView﹕ unregisterIRListener() is called
>D/AbsListView﹕ onVisibilityChanged() is called, visibility : 4
>D/AbsListView﹕ unregisterIRListener() is called
>D/AbsListView﹕ onDetachedFromWindow
编辑: 当调试器连接时,它似乎可以在手机上工作。