嗨,我有下面的代码可以让用户捕获图像或从图库中选择它。我捕获图像保存它,然后尝试从图库中选择图像,图库应用程序总是崩溃。
AlertDialog.Builder photoDialog = new AlertDialog.Builder(this);
photoDialog
.setTitle("Photo source")
.setCancelable(true)
.setPositiveButton("Open Gallery",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
startActivityForResult(
new Intent( Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI),
54);
}
})
.setNegativeButton("Open Camera",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
String fileName = "temp.jpg";
ContentValues values = new ContentValues();
values.put(MediaStore.Images.Media.TITLE,
fileName);
mCapturedImageURI = getContentResolver()
.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
Intent intent = new Intent( MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, mCapturedImageURI);
startActivityForResult(intent, 96);
}
});
photoDialog.show();
日志
I/ActivityManager( 222): Starting: Intent { act=android.intent.action.PICK dat=content://media/external/images/media cmp=com.cooliris.media/.Gallery } from pid 13631
I/SiteInspection(13631): In SiteInspectionDetailsActivity.onSaveInstanceState() .......
I/ActivityManager( 222): Start proc com.cooliris.media for activity com.cooliris.media/.Gallery: pid=13685 uid=10028 gids={1015, 3003}
W/InputManagerService( 222): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@4091f7c8
D/BackgroundDataSender(13631): BackgroundDataService started
D/BackgroundLogSender(13631): BackgroundLogService started
D/BackgroundLogSender(13631): true
D/BackgroundLogSender(13631): logsender ted
I/ActivityThread(13685): Pub com.cooliris.picasa.contentprovider: com.cooliris.picasa.PicasaContentProvider
I/Gallery (13685): onCreate
D/CacheService(13685): Refreshing Cache for all items
I/CacheService(13685): Refreshing cache.
E/DiskCache(13685): Unable to create or tempFile /mnt/sdcard/Android/data/com.cooliris.media/cache/local-album-cache
I/CacheService(13685): Building albums.
I/ActivityManager( 222): Displayed com.cooliris.media/.Gallery: +659ms
E/DiskCache(13685): Unable to create or tempFile /mnt/sdcard/Android/data/com.cooliris.media/cache/local-album-cache
I/CacheService(13685): Done building albums.
I/CacheService(13685): Building items.
E/DiskCache(13685): Unable to create or tempFile /mnt/sdcard/Android/data/com.cooliris.media/cache/local-album-cache
I/CacheService(13685): Done building items.
I/RenderView(13685): First Draw
I/MediaFeed(13685): Replacing media set -1595679508
I/MediaFeed(13685): Replacing media set 1506676782
D/CacheService(13685): Refreshing Cache for all items
I/CacheService(13685): Refreshing cache.
E/DiskCache(13685): Unable to create or tempFile /mnt/sdcard/Android/data/com.cooliris.media/cache/local-album-cache
I/CacheService(13685): Building albums.
W/IInputConnectionWrapper(13631): showStatusIcon on inactive InputConnection
E/DiskCache(13685): Unable to create or tempFile /mnt/sdcard/Android/data/com.cooliris.media/cache/local-album-cache
I/CacheService(13685): Done building albums.
I/CacheService(13685): Building items.
D/BackgroundDataSender(13631): BackgroundDataService started
D/BackgroundLogSender(13631): BackgroundLogService started
D/BackgroundLogSender(13631): true
D/BackgroundLogSender(13631): logsender ted
E/DiskCache(13685): Unable to create or tempFile /mnt/sdcard/Android/data/com.cooliris.media/cache/local-album-cache
I/CacheService(13685): Done building items.
I/GridLayer(13685): Slot changing from -1 to -1
D/BackgroundDataSender(13631): BackgroundDataService started
D/BackgroundLogSender(13631): BackgroundLogService started
D/BackgroundLogSender(13631): true
D/BackgroundLogSender(13631): logsender ted
D/BackgroundDataSender(13631): BackgroundDataService started
D/BackgroundLogSender(13631): BackgroundLogService started
D/BackgroundLogSender(13631): true
D/BackgroundLogSender(13631): logsender ted
D/wpa_supplicant( 456): wpa_supplicant_scan: scan_req = 0, ap_scan = 1
D/wpa_supplicant( 456): Starting AP scan (broadcast SSID)
D/wpa_supplicant( 456): wpa_driver_wext_scan: specific scan = 0
D/wpa_supplicant( 456): Scan requested (ret=0) - scan timeout 30 seconds
I/GridLayer(13685): Slot changing from 0 to 0
I/RenderView(13685): Texture creation fail, glError 1281
D/BackgroundDataSender(13631): BackgroundDataService started
D/BackgroundLogSender(13631): BackgroundLogService started
D/BackgroundLogSender(13631): true
D/BackgroundLogSender(13631): logsender ted
I/CacheService(13685): Built thumbnail and screennail for 19 in 628
W/dalvikvm(13685): threadid=11: thread exiting with uncaught exception (group=0x40015560)
E/AndroidRuntime(13685): FATAL EXCEPTION: GLThread 13
E/AndroidRuntime(13685): java.lang.NullPointerException
E/AndroidRuntime(13685): at com.cooliris.media.GridDrawManager.drawBlendedComponents(GridDrawManager.java:716)
E/AndroidRuntime(13685): at com.cooliris.media.GridLayer.renderBlended(GridLayer.java:831)
E/AndroidRuntime(13685): at com.cooliris.media.RenderView.onDrawFrame(RenderView.java:684)
E/AndroidRuntime(13685): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1363)
E/AndroidRuntime(13685): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118)
I/RenderView(13685): OnPause RenderView com.cooliris.media.RenderView@40578d58
W/ActivityManager( 222): Force finishing activity com.cooliris.media/.Gallery