首页
社区
课程
招聘
[求助][求助]听纳闷的 关于surfaceView 模拟和真机
2015-5-13 08:24 4912

[求助][求助]听纳闷的 关于surfaceView 模拟和真机

2015-5-13 08:24
4912
下面这个代码 如果在模拟器调试 就可以弹出提示框 
但是 如果换在真机 我华为 小米都试 执行到 camera.takePicture会异常 

在现行代码基础上 为什么呢 怎么解决好呢

package com.example.asdddddd;  

import java.io.IOException;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.hardware.Camera;
import android.hardware.Camera.PictureCallback;
import android.os.Bundle;
import android.view.SurfaceHolder;
import android.view.SurfaceView;
  


public class MainActivity  extends Activity {
	private SurfaceView surfaceView; 
	public Camera camera;
    private SurfaceHolder holder;
    
    private PictureCallback pic = new PictureCallback() {
        public void onPictureTaken(byte[] data, Camera camera) {
          AlertDialog.Builder builder  = new Builder(MainActivity.this);
           builder.setTitle("确认" ) ;
           builder.setMessage("这是一个简单消息框" ) ;
           builder.setPositiveButton("是" ,  null );
           builder.show(); 
          camera.release();
          camera = null;
   
        }};
        
    
    protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      
    

          surfaceView = new SurfaceView(this);
          setContentView(surfaceView);
          SurfaceHolder holder = surfaceView.getHolder(); 
                  
          camera = Camera.open(); 
         
        try {
        camera.setPreviewDisplay(holder);
      } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      } 
        camera.startPreview(); 
         try {
                Thread.currentThread().sleep(3000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        camera.takePicture(null, null, pic); 
    }}


阿里云助力开发者!2核2G 3M带宽不限流量!6.18限时价,开 发者可享99元/年,续费同价!

收藏
点赞0
打赏
分享
最新回复 (4)
雪    币: 41
活跃值: (82)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
wuyuhan 2015-5-13 09:53
2
0
直接看logcat 报什么错啊
雪    币: 206
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
嫩肥羊 2015-5-13 09:55
3
0
没提示 不然 大哥你试试
雪    币: 206
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
嫩肥羊 2015-5-13 13:26
4
0
05-13 13:25:12.050: I/QualcommCameraHardware(23446): stopPreviewInternal E: 1
05-13 13:25:12.050: E/QualcommCameraHardware(23446): stopPreviewInternal, J_mCameraRunning = 1
05-13 13:25:12.050: I/QualcommCameraHardware(23446): stopPreviewInternal: Preview is stopped already
05-13 13:25:12.050: I/QualcommCameraHardware(23446): stopPreviewInternal X: 1
05-13 13:25:12.050: V/QualcommCameraHardware(23446): initRaw E: picture size=640x480
05-13 13:25:12.060: V/QualcommCameraHardware(23446): initRaw: initializing mRawHeap.
05-13 13:25:12.060: V/QualcommCameraHardware(23446): createSnapshotMemory, numRaw=1, numJpeg=1, initJpegHeap=1, format=1, numCapture=1
05-13 13:25:12.060: E/QualcommCameraHardware(23446): bool android::QualcommCameraHardware::createSnapshotMemory(int, int, bool, int)  Raw memory index: 0 , fd is 34
05-13 13:25:12.060: E/QualcommCameraHardware(23446): Received following info for raw mapped data:0x4211f000,handle:0x1925de0, size:460800,release:0x407c7bed
05-13 13:25:12.070: E/QualcommCameraHardware(23446): Registering buffer 0 with fd :34 with kernel
05-13 13:25:12.070: V/QualcommCameraHardware(23446): register_buf:  reg = 0 buffer = 0x4211f000
05-13 13:25:12.070: E/QualcommCameraHardware(23446): bool android::QualcommCameraHardware::createSnapshotMemory(int, int, bool, int)  Jpeg memory index: 0 , fd is 593717358
05-13 13:25:12.070: E/QualcommCameraHardware(23446): Received following info for jpeg mapped data:0x422a1000,handle:0x192ad60, size:460800,release:0x407c7bed
05-13 13:25:12.070: E/QualcommCameraHardware(23446): Locking and registering Thumbnail buffer(s)
05-13 13:25:12.080: A/libc(23446): Fatal signal 11 (SIGSEGV) at 0x80498048 (code=1)
雪    币: 206
活跃值: (10)
能力值: ( LV2,RANK:10 )
在线值:
发帖
回帖
粉丝
嫩肥羊 2015-5-13 14:10
5
0
这是整个 debug的
05-13 13:25:12.080: A/libc(23446): Fatal signal 11 (SIGSEGV) at 0x80498048 (code=1)
05-13 13:25:12.580: I/DEBUG(4548): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
05-13 13:25:12.580: I/DEBUG(4548): Build fingerprint: 'Huawei/C8812/hwc8812:4.0.3/HuaweiC8812/C92B950:user/ota-rel-keys,release-keys'
05-13 13:25:12.580: I/DEBUG(4548): pid: 23446, tid: 23450  >>> /system/bin/mediaserver <<<
05-13 13:25:12.580: I/DEBUG(4548): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 80498048
05-13 13:25:12.580: I/DEBUG(4548):  r0 00000044  r1 80598058  r2 9bcd5c5f  r3 80498048
05-13 13:25:12.590: I/DEBUG(4548):  r4 0192b418  r5 0192b7b8  r6 002a0029  r7 00000000
05-13 13:25:12.590: I/DEBUG(4548):  r8 0192b588  r9 412bcb3f  10 00000001  fp 00000000
05-13 13:25:12.590: I/DEBUG(4548):  ip 00000001  sp 416cab68  lr 412b347f  pc 412b354e  cpsr a0000030
05-13 13:25:12.590: I/DEBUG(4548):  d0  7562206c69616e66  d1  6d75685420676e66
05-13 13:25:12.590: I/DEBUG(4548):  d2  70616d2067657065  d3  6174616420646572
05-13 13:25:12.590: I/DEBUG(4548):  d4  2c3832312c353231  d5  2c3533312c313331
05-13 13:25:12.590: I/DEBUG(4548):  d6  2c3134312c383331  d7  2c3834312c343431
05-13 13:25:12.590: I/DEBUG(4548):  d8  0000000000000000  d9  0000000000000000
05-13 13:25:12.590: I/DEBUG(4548):  d10 0000000000000000  d11 0000000000000000
05-13 13:25:12.590: I/DEBUG(4548):  d12 0000000000000000  d13 0000000000000000
05-13 13:25:12.590: I/DEBUG(4548):  d14 0000000000000000  d15 0000000000000000
05-13 13:25:12.590: I/DEBUG(4548):  d16 2c3535312c313531  d17 2c3236312c383531
05-13 13:25:12.590: I/DEBUG(4548):  d18 2c3037312c363631  d19 2c3837312c343731
05-13 13:25:12.590: I/DEBUG(4548):  d20 2c3638312c323831  d21 2c3539312c303931
05-13 13:25:12.600: I/DEBUG(4548):  d22 2c3430322c323032  d23 2c3431322c393032
05-13 13:25:12.600: I/DEBUG(4548):  d24 3e66376972bea4d0  d25 0000000000000000
05-13 13:25:12.600: I/DEBUG(4548):  d26 0000000000000000  d27 0000000000000000
05-13 13:25:12.600: I/DEBUG(4548):  d28 0000000000000000  d29 0000000000000000
05-13 13:25:12.600: I/DEBUG(4548):  d30 0000000000000000  d31 0000000000000000
05-13 13:25:12.600: I/DEBUG(4548):  scr 20000010
05-13 13:25:12.730: I/DEBUG(4548):          #00  pc 0001454e  /system/lib/hw/camera.msm7627a.so (_ZN7android22QualcommCameraHardware20createSnapshotMemoryEiibi)
05-13 13:25:12.740: I/DEBUG(4548):          #01  pc 0001a014  /system/lib/hw/camera.msm7627a.so (_ZN7android22QualcommCameraHardware7initRawEb)
05-13 13:25:12.740: I/DEBUG(4548):          #02  pc 0001a5ae  /system/lib/hw/camera.msm7627a.so (_ZN7android22QualcommCameraHardware11takePictureEv)
05-13 13:25:12.740: I/DEBUG(4548):          #03  pc 0000d1e2  /system/lib/hw/camera.msm7627a.so (take_picture)
05-13 13:25:12.740: I/DEBUG(4548):          #04  pc 00008df4  /system/lib/libcameraservice.so (_ZN7android13CameraService6Client11takePictureEi)
05-13 13:25:12.740: I/DEBUG(4548):          #05  pc 00015a5a  /system/lib/libcamera_client.so (_ZN7android8BnCamera10onTransactEjRKNS_6ParcelEPS1_j)
05-13 13:25:12.740: I/DEBUG(4548):          #06  pc 00017e88  /system/lib/libbinder.so (_ZN7android7BBinder8transactEjRKNS_6ParcelEPS1_j)
05-13 13:25:12.740: I/DEBUG(4548):          #07  pc 0001b192  /system/lib/libbinder.so (_ZN7android14IPCThreadState14executeCommandEi)
05-13 13:25:12.740: I/DEBUG(4548):          #08  pc 0001b36e  /system/lib/libbinder.so (_ZN7android14IPCThreadState14joinThreadPoolEb)
05-13 13:25:12.740: I/DEBUG(4548):          #09  pc 000204bc  /system/lib/libbinder.so
05-13 13:25:12.740: I/DEBUG(4548):          #10  pc 0002155a  /system/lib/libutils.so (_ZN7android6Thread11_threadLoopEPv)
05-13 13:25:12.740: I/DEBUG(4548):          #11  pc 00021ba0  /system/lib/libutils.so
05-13 13:25:12.740: I/DEBUG(4548):          #12  pc 00012e14  /system/lib/libc.so (__thread_entry)
05-13 13:25:12.740: I/DEBUG(4548):          #13  pc 00012968  /system/lib/libc.so (pthread_create)
05-13 13:25:12.740: I/DEBUG(4548): code around pc:
05-13 13:25:12.740: I/DEBUG(4548): 412b352c 20064a3a 447a4631 ea18f7f8 6aa0f8d4  :J. 1FzD.......j
05-13 13:25:12.740: I/DEBUG(4548): 412b353c 1aa4f8d4 9109960b 36c8f8d5 f0002b00  ...........6.+..
05-13 13:25:12.740: I/DEBUG(4548): 412b354c 681e808c f8df2002 4a3290c8 44f969f7  ...h. ....2J.i.D
05-13 13:25:12.740: I/DEBUG(4548): 412b355c 4649447a 27009700 f7f868f3 68f2ea00  zDIF...'.h.....h
05-13 13:25:12.740: I/DEBUG(4548): 412b356c 97012301 92004638 69f12203 ebcaf7f8  .#..8F...".i....
05-13 13:25:12.740: I/DEBUG(4548): code around lr:
05-13 13:25:12.750: I/DEBUG(4548): 412b345c 45a89d09 f8dddbce 4960a01c 4a602006  ...E......`I. `J
05-13 13:25:12.750: I/DEBUG(4548): 412b346c 78b8f504 4f5f4479 f504447a f7f87568  ...xyD_OzD..hu..
05-13 13:25:12.750: I/DEBUG(4548): 412b347c 495dea76 447f4b5d f04f4479 447b0b00  v.]I]K.DyDO...{D
05-13 13:25:12.750: I/DEBUG(4548): 412b348c 93089107 e120970a 6a60f8d4 d04d2e00  ...... ...`j..M.
05-13 13:25:12.750: I/DEBUG(4548): 412b349c 26c8f8d5 d0492a00 20064e55 447e4a55  ...&.*I.UN. UJ~D
05-13 13:25:12.750: I/DEBUG(4548): memory map around addr 80498048:
05-13 13:25:12.750: I/DEBUG(4548): 4232f000-4242e000 
05-13 13:25:12.750: I/DEBUG(4548): (no map for address)
05-13 13:25:12.750: I/DEBUG(4548): b0001000-b0009000 /system/bin/linker
05-13 13:25:12.750: I/DEBUG(4548): stack:
05-13 13:25:12.750: I/DEBUG(4548):     416cab28  0191fd40  [heap]
05-13 13:25:12.750: I/DEBUG(4548):     416cab2c  0192ad70  [heap]
05-13 13:25:12.750: I/DEBUG(4548):     416cab30  0191fd58  [heap]
05-13 13:25:12.750: I/DEBUG(4548):     416cab34  40165095  /system/lib/libutils.so
05-13 13:25:12.750: I/DEBUG(4548):     416cab38  0192ad60  [heap]
05-13 13:25:12.750: I/DEBUG(4548):     416cab3c  407c9215  /system/lib/libcameraservice.so
05-13 13:25:12.750: I/DEBUG(4548):     416cab40  ffffffff  
05-13 13:25:12.750: I/DEBUG(4548):     416cab44  9bcd5c5f  
05-13 13:25:12.750: I/DEBUG(4548):     416cab48  0192b418  [heap]
05-13 13:25:12.750: I/DEBUG(4548):     416cab4c  0192b418  [heap]
05-13 13:25:12.750: I/DEBUG(4548):     416cab50  0192b7b8  [heap]
05-13 13:25:12.750: I/DEBUG(4548):     416cab54  0192b7f8  [heap]
05-13 13:25:12.750: I/DEBUG(4548):     416cab58  0000c2f7  
05-13 13:25:12.750: I/DEBUG(4548):     416cab5c  412b347f  /system/lib/hw/camera.msm7627a.so
05-13 13:25:12.750: I/DEBUG(4548):     416cab60  df0027ad  
05-13 13:25:12.750: I/DEBUG(4548):     416cab64  00000000  
05-13 13:25:12.750: I/DEBUG(4548): #00 416cab68  0192ad60  [heap]
05-13 13:25:12.750: I/DEBUG(4548):     416cab6c  00070800  
05-13 13:25:12.750: I/DEBUG(4548):     416cab70  407c7bed  /system/lib/libcameraservice.so
05-13 13:25:12.750: I/DEBUG(4548):     416cab74  00000004  
05-13 13:25:12.750: I/DEBUG(4548):     416cab78  00000001  
05-13 13:25:12.750: I/DEBUG(4548):     416cab7c  00000001  
05-13 13:25:12.750: I/DEBUG(4548):     416cab80  0192b548  [heap]
05-13 13:25:12.750: I/DEBUG(4548):     416cab84  412bcb3f  /system/lib/hw/camera.msm7627a.so
05-13 13:25:12.750: I/DEBUG(4548):     416cab88  412c34d4  /system/lib/hw/camera.msm7627a.so
05-13 13:25:12.750: I/DEBUG(4548):     416cab8c  80598058  
05-13 13:25:12.760: I/DEBUG(4548):     416cab90  412bf77d  /system/lib/hw/camera.msm7627a.so
05-13 13:25:12.760: I/DEBUG(4548):     416cab94  002a0029  
05-13 13:25:12.760: I/DEBUG(4548):     416cab98  4175e745  /system/lib/liboemcamera.so
05-13 13:25:12.760: I/DEBUG(4548):     416cab9c  0192b418  [heap]
05-13 13:25:12.760: I/DEBUG(4548):     416caba0  412c5ac4  /system/lib/hw/camera.msm7627a.so
05-13 13:25:12.760: I/DEBUG(4548):     416caba4  412bcb3f  /system/lib/hw/camera.msm7627a.so
05-13 13:25:12.760: I/DEBUG(4548):     416caba8  0192b430  [heap]
05-13 13:25:12.760: I/DEBUG(4548):     416cabac  00000001  
05-13 13:25:12.760: I/DEBUG(4548):     416cabb0  00000001  
05-13 13:25:12.760: I/DEBUG(4548):     416cabb4  0192b548  [heap]
05-13 13:25:12.760: I/DEBUG(4548):     416cabb8  0192b584  [heap]
05-13 13:25:12.760: I/DEBUG(4548):     416cabbc  412b9019  /system/lib/hw/camera.msm7627a.so
05-13 13:25:12.760: I/DEBUG(4548): #01 416cabc0  00000001  
05-13 13:25:12.760: I/DEBUG(4548):     416cabc4  412c5f8c  /system/lib/hw/camera.msm7627a.so
05-13 13:25:12.760: I/DEBUG(4548):     416cabc8  00000000  
05-13 13:25:12.760: I/DEBUG(4548):     416cabcc  0004b000  
05-13 13:25:12.760: I/DEBUG(4548):     416cabd0  00070800  
05-13 13:25:12.760: I/DEBUG(4548):     416cabd4  00000280  
05-13 13:25:12.760: I/DEBUG(4548):     416cabd8  000001e0  
05-13 13:25:12.760: I/DEBUG(4548):     416cabdc  416cac18  
05-13 13:25:12.760: I/DEBUG(4548):     416cabe0  00000000  
05-13 13:25:12.760: I/DEBUG(4548):     416cabe4  ffffffff  
05-13 13:25:12.760: I/DEBUG(4548):     416cabe8  37327837  
05-13 13:25:12.760: I/DEBUG(4548):     416cabec  417e0061  
05-13 13:25:12.760: I/DEBUG(4548):     416cabf0  417e94e0  
05-13 13:25:12.760: I/DEBUG(4548):     416cabf4  0000000c  
05-13 13:25:12.760: I/DEBUG(4548):     416cabf8  412c5f8c  /system/lib/hw/camera.msm7627a.so
05-13 13:25:12.760: I/DEBUG(4548):     416cabfc  417e94f4  
05-13 13:25:12.760: I/DEBUG(4548):     416cac00  0192b548  [heap]
05-13 13:25:12.760: I/DEBUG(4548):     416cac04  0192b584  [heap]
05-13 13:25:12.770: I/DEBUG(4548):     416cac08  019335b8  [heap]
05-13 13:25:12.770: I/DEBUG(4548):     416cac0c  417e94f4  
05-13 13:25:12.770: I/DEBUG(4548):     416cac10  00000001  
05-13 13:25:12.770: I/DEBUG(4548):     416cac14  00000002  
05-13 13:25:12.770: I/DEBUG(4548):     416cac18  412c6408  
05-13 13:25:12.770: I/DEBUG(4548):     416cac1c  412c1ffb  /system/lib/hw/camera.msm7627a.so
05-13 13:25:12.770: I/DEBUG(4548):     416cac20  0192b548  [heap]
05-13 13:25:12.770: I/DEBUG(4548):     416cac24  41760eb3  /system/lib/liboemcamera.so
05-13 13:25:12.770: I/DEBUG(4548):     416cac28  019335b8  [heap]
05-13 13:25:12.770: I/DEBUG(4548):     416cac2c  00000002  
05-13 13:25:12.770: I/DEBUG(4548):     416cac30  4175f8e1  /system/lib/liboemcamera.so
05-13 13:25:12.770: I/DEBUG(4548):     416cac34  417e93c0  
05-13 13:25:12.770: I/DEBUG(4548):     416cac38  0000000d  
05-13 13:25:12.770: I/DEBUG(4548):     416cac3c  00000002  
05-13 13:25:12.770: I/DEBUG(4548):     416cac40  00000000  
05-13 13:25:12.770: I/DEBUG(4548):     416cac44  9bcd5c5f  
05-13 13:25:12.770: I/DEBUG(4548):     416cac48  412c1ffb  /system/lib/hw/camera.msm7627a.so
05-13 13:25:12.770: I/DEBUG(4548):     416cac4c  0192b418  [heap]
05-13 13:25:12.770: I/DEBUG(4548):     416cac50  412c5ac4  /system/lib/hw/camera.msm7627a.so
05-13 13:25:12.770: I/DEBUG(4548):     416cac54  0192b544  [heap]
05-13 13:25:12.770: I/DEBUG(4548):     416cac58  412c620c  
05-13 13:25:12.770: I/DEBUG(4548):     416cac5c  412c6408  
05-13 13:25:12.770: I/DEBUG(4548):     416cac60  412c1ffb  /system/lib/hw/camera.msm7627a.so
05-13 13:25:12.780: I/DEBUG(4548):     416cac64  0192b548  [heap]
05-13 13:25:12.780: I/DEBUG(4548):     416cac68  0192b584  [heap]
05-13 13:25:12.780: I/DEBUG(4548):     416cac6c  412b95b3  /system/lib/hw/camera.msm7627a.so
游客
登录 | 注册 方可回帖
返回