三星Galaxy不会返回(位图)data.getExtras()得到的。(QUOT;数据"); [英] Samsung Galaxy wont return (Bitmap) data.getExtras().get("data");

查看:533
本文介绍了三星Galaxy不会返回(位图)data.getExtras()得到的。(QUOT;数据");的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 字符串strAvatarPrompt =把你的照片保存为你的头像!;
    意图pictureIntent =新的意图(android.provider.MediaStore.ACTION_IM​​AGE_CAPTURE);
    pictureIntent.putExtra(MediaStore.EXTRA_OUTPUT,imageUriToSaveCameraImageTo);
    startActivityForResult(Intent.createChooser(pictureIntent,strAvatarPrompt),TAKE_AVATAR_CAMERA_REQUEST);

保护无效onActivityResult(INT申请code,INT结果code,意图数据){
        开关(要求code){
        案例TAKE_AVATAR_CAMERA_REQUEST:
            如果(结果code == Activity.RESULT_CANCELED){
            }
            否则,如果(结果code == Activity.RESULT_OK){
                。位图cameraPic =(位图)data.getExtras()获得(数据);

                如果(cameraPic!= NULL){
                    尝试 {
                        saveAvatar(cameraPic);
                    }
 

我有code我的应用程序来拍照的用户。它工作正常,在HTC渴望。然而在三星Galaxy崩溃在点
  。位图cameraPic =(位图)data.getExtras()获得(数据);

我不知道为什么它不工作?

堆栈 -

  03-31 16:35:15.593:VERBOSE /窗口管理器(2497):提供toWindow {47fe4340 com.sec.android.app.camera/com.sec.android.app。 camera.CropImage暂停= FALSE}
03-31 16:35:15.761:VERBOSE /窗口管理器(2497):提供toWindow {47fe4340 com.sec.android.app.camera/com.sec.android.app.camera.CropImage暂停= FALSE}
03-31 16:35:15.761:VERBOSE / CropImage(6885):作物=无,回报=指定的URI
03-31 16:35:15.773:VERBOSE / CropImage(6885):在onPause
03-31 16:35:15.780:ERROR /窗口管理器(2497):覆盖轮换从1值
03-31 16:35:15.780:VERBOSE /窗口管理(2497):旋转从0变为1(forceApp = 0,REQ = 0)
03-31 16:35:15.784:信息/窗口管理器(2497):设置旋转1,animFlags = 1
03-31 16:35:15.800:ERROR / SurfaceFlinger(2497):表面抛油:: setOrientation mIsRotationPossible = 0,nBackupOrientationValue = 1
03-31 16:35:15.804:信息/ TVOUT观察员(2497):setTvoutOrientation旋转= 1
03-31 16:35:15.804:ERROR / TVOUT观察员(2497):SetOrientation
03-31 16:35:15.804:信息/ ActivityManager(2497):配置改变:{规模= 1.0 IMSI =一十分之二百三十四LOC = EN_GB触摸= 3键= 1/1/2 NAV = 1/1的广州澳凌= 2的布局= 35 uiMode = 17以次= 96 FlipFont = 0}
03-31 16:35:15.808:DEBUG / PhoneApp(2588):updateProximitySensorMode:状态= IDLE
03-31 16:35:15.855:DEBUG / OPPBaseService(7980):主/ 1] onConfigurationChanged()
03-31 16:35:15.870:VERBOSE /摄像机(5292):--onActivityResult  - 要求code:2001
03-31 16:35:15.870:VERBOSE /摄像机(5292):--onActivityResult  - 结果code:-1
03-31 16:35:15.870:VERBOSE /摄像机(5292):--onActivityResult  - 数据:意向{act =被内联数据(有群众演员)}
03-31 16:35:15.882:WARN / ActivityManager(2497):为HistoryRecord重复结束请求{481527f8 com.sec.android.app.camera/.Camera}
03-31 16:35:16.038:VERBOSE / CropImage(6885):的onDestroy
 

解决方案

有些设备不返回数据额外的;其他人只能在额外返回一个很小的缩略图。你最好读取SD卡的位置在文件 EXTRA_OUTPUT (你在你的原意正在已经要求)的,如果它是可用,回落至回调数据额外只有当你无法读取 EXTRA_OUTPUT 。请参见此相关的SO质疑

    String strAvatarPrompt = "Take your picture to store as your avatar!";
    Intent pictureIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
    pictureIntent.putExtra( MediaStore.EXTRA_OUTPUT, imageUriToSaveCameraImageTo );
    startActivityForResult(Intent.createChooser(pictureIntent, strAvatarPrompt), TAKE_AVATAR_CAMERA_REQUEST);

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        switch (requestCode) {
        case TAKE_AVATAR_CAMERA_REQUEST:
            if (resultCode == Activity.RESULT_CANCELED) {
            } 
            else if (resultCode == Activity.RESULT_OK) {
                Bitmap cameraPic = (Bitmap) data.getExtras().get("data");           

                if (cameraPic != null) {
                    try {
                        saveAvatar(cameraPic);
                    } 

I have code for users of my app to take pictures. It works fine on the HTC desire. However on the Samsung Galaxy it crashes at the point
Bitmap cameraPic = (Bitmap) data.getExtras().get("data");

I dont know why it is not working?

Stack-

03-31 16:35:15.593: VERBOSE/WindowManager(2497): Delivering toWindow{47fe4340 com.sec.android.app.camera/com.sec.android.app.camera.CropImage paused=false}
03-31 16:35:15.761: VERBOSE/WindowManager(2497): Delivering toWindow{47fe4340 com.sec.android.app.camera/com.sec.android.app.camera.CropImage paused=false}
03-31 16:35:15.761: VERBOSE/CropImage(6885): Crop = no, Return = specified uri
03-31 16:35:15.773: VERBOSE/CropImage(6885): onPause
03-31 16:35:15.780: ERROR/WindowManager(2497): Overwriting rotation value from 1
03-31 16:35:15.780: VERBOSE/WindowManager(2497): Rotation changed to 1 from 0 (forceApp=0, req=0)
03-31 16:35:15.784: INFO/WindowManager(2497): Setting rotation to 1, animFlags=1
03-31 16:35:15.800: ERROR/SurfaceFlinger(2497): Surface Flinger::setOrientation  mIsRotationPossible = 0, nBackupOrientationValue = 1  
03-31 16:35:15.804: INFO/TvOut-Observer(2497): setTvoutOrientation rotation =  1
03-31 16:35:15.804: ERROR/TvOut-Observer(2497): SetOrientation
03-31 16:35:15.804: INFO/ActivityManager(2497): Config changed: { scale=1.0 imsi=234/10 loc=en_GB touch=3 keys=1/1/2 nav=1/1 orien=2 layout=35 uiMode=17 seq=96 FlipFont=0}
03-31 16:35:15.808: DEBUG/PhoneApp(2588): updateProximitySensorMode: state = IDLE
03-31 16:35:15.855: DEBUG/OPPBaseService(7980): [main/1] onConfigurationChanged()
03-31 16:35:15.870: VERBOSE/Camera(5292): --onActivityResult--requestCode: 2001
03-31 16:35:15.870: VERBOSE/Camera(5292): --onActivityResult--resultCode: -1
03-31 16:35:15.870: VERBOSE/Camera(5292): --onActivityResult--data: Intent { act=inline-data (has extras) }
03-31 16:35:15.882: WARN/ActivityManager(2497): Duplicate finish request for HistoryRecord{481527f8 com.sec.android.app.camera/.Camera}
03-31 16:35:16.038: VERBOSE/CropImage(6885): onDestroy

解决方案

Some devices don't return the DATA extra; others only return a very small thumbnail in the extra. You're best off reading the file from the SD card location in EXTRA_OUTPUT (which you're already requesting in your original intent) in the callback if it's available, falling back to the data extra only if you can't read the EXTRA_OUTPUT. See this related SO question.

这篇关于三星Galaxy不会返回(位图)data.getExtras()得到的。(QUOT;数据");的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆