Android中的摄像机意图和优先级队列
我目前正在编写一个Android应用程序(API级别2.3.3),它涉及从通过照相机意图拍摄的照片中获取300个最高灰度值。 接下来,函数(主要是数学和一些基于日历/时钟的)对结果值执行。 我正在使用Eclipse /模拟摄像头。
相机将启动并且照片拍摄没有问题,当我尝试保存照片(以及像素排序和数学/日历功能发生时)时,应用程序会崩溃。
我用相机意图和主变量(Y)的“虚拟”值测试了应用程序,并且这很好地工作。
出了什么问题?
以下是相关的代码部分:
int[] pixels;
Button button = (Button) findViewById(R.id.button);
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String _path = Environment.getExternalStorageDirectory() + File.separator + "sunpic.jpg";
File file = new File(_path);
Uri outputFileUri = Uri.fromFile(file);
Intent intent = new Intent(
android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
startActivityForResult(intent, 1);
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
switch(requestCode) {
case (1): {
if (resultCode == RESULT_OK) {
Uri outputFileUri = data.getData();
try {
Bitmap bmp = android.provider.MediaStore.Images.Media.getBitmap(this.getContentResolver(), outputFileUri);
bmp.getPixels(pixels, 0, bmp.getWidth(), 0, 0, bmp.getWidth(), bmp.getHeight());
for(int x = 0; x < bmp.getWidth(); ++x) {
for(int y = 0; y < bmp.getHeight(); ++y) {
int index = y * bmp.getWidth() + x;
int R = (pixels[index] >> 16) & 0xff;
int G = (pixels[index] >> 8) & 0xff;
int B = pixels[index] & 0xff;
Double Grey = (0.299 * R + 0.587 * G + 0.114 * B);
int topSize = 300;
// priority queue to save the largest topSize values
PriorityQueue<Double> pq;
pq = new PriorityQueue<Double>(topSize+1);
double nv = Grey.floatValue();
if (pq.size() < topSize || pq.peek() < nv) {
// remove the smallest value from the queue only if it is full
if (pq.size() == topSize) {
pq.poll();
}
pq.add(nv);
}
double sum = 0;
for(Double d : pq) {
sum += d;
}
double Y = sum / 300;
在XML Manifest中,我有:
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-feature android:name="android.hardware.camera"/>
LogCat错误/警告:
06-09 02:10:40.076: E/SurfaceFlinger(37): ro.sf.lcd_density must be defined as a build property
06-09 02:10:41.646: E/Trace(4464): error opening trace file: No such file or directory (2)
06-09 02:10:49.907: W/ActivityManager(289): Launch timeout has expired, giving up wake lock!
06-09 02:10:50.817: E/SurfaceFlinger(37): ro.sf.lcd_density must be defined as a build property
06-09 02:10:51.106: W/ActivityManager(289): Activity idle timeout for ActivityRecord{40ec7900 inActivity}
06-09 02:10:55.547: W/ActivityManager(289): Unable to start service Intent { act=com.android.email.ACCOUNT_INTENT } U=0: not found
06-09 02:10:55.587: W/EGL_emulation(4464): eglSurfaceAttrib not implemented
06-09 02:10:56.477: W/ActivityManager(289): Unable to start service Intent { act=com.android.email.ACCOUNT_INTENT } U=0: not found
06-09 02:10:56.487: E/ActivityThread(707): Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40cfe978 that was originally bound here
06-09 02:10:56.487: E/ActivityThread(707): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40cfe978 that was originally bound here
06-09 02:10:56.487: E/ActivityThread(707): at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
06-09 02:10:56.487: E/ActivityThread(707): at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
06-09 02:10:56.487: E/ActivityThread(707): at android.app.ContextImpl.bindService(ContextImpl.java:1418)
06-09 02:10:56.487: E/ActivityThread(707): at android.app.ContextImpl.bindService(ContextImpl.java:1407)
06-09 02:10:56.487: E/ActivityThread(707): at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
06-09 02:10:56.487: E/ActivityThread(707): at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
06-09 02:10:56.487: E/ActivityThread(707): at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
06-09 02:10:56.487: E/ActivityThread(707): at com.android.emailcommon.service.ServiceProxy.test(ServiceProxy.java:191)
06-09 02:10:56.487: E/ActivityThread(707): at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1850)
06-09 02:10:56.487: E/ActivityThread(707): at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
06-09 02:10:56.487: E/ActivityThread(707): at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
06-09 02:10:56.487: E/ActivityThread(707): at android.os.AsyncTask$2.call(AsyncTask.java:287)
06-09 02:10:56.487: E/ActivityThread(707): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
06-09 02:10:56.487: E/ActivityThread(707): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
06-09 02:10:56.487: E/ActivityThread(707): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
06-09 02:10:56.487: E/ActivityThread(707): at java.lang.Thread.run(Thread.java:856)
06-09 02:10:56.510: E/StrictMode(707): null
06-09 02:10:56.510: E/StrictMode(707): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40cfe978 that was originally bound here
06-09 02:10:56.510: E/StrictMode(707): at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
06-09 02:10:56.510: E/StrictMode(707): at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
06-09 02:10:56.510: E/StrictMode(707): at android.app.ContextImpl.bindService(ContextImpl.java:1418)
06-09 02:10:56.510: E/StrictMode(707): at android.app.ContextImpl.bindService(ContextImpl.java:1407)
06-09 02:10:56.510: E/StrictMode(707): at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
06-09 02:10:56.510: E/StrictMode(707): at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
06-09 02:10:56.510: E/StrictMode(707): at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
06-09 02:10:56.510: E/StrictMode(707): at com.android.emailcommon.service.ServiceProxy.test(ServiceProxy.java:191)
06-09 02:10:56.510: E/StrictMode(707): at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1850)
06-09 02:10:56.510: E/StrictMode(707): at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
06-09 02:10:56.510: E/StrictMode(707): at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
06-09 02:10:56.510: E/StrictMode(707): at android.os.AsyncTask$2.call(AsyncTask.java:287)
06-09 02:10:56.510: E/StrictMode(707): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
06-09 02:10:56.510: E/StrictMode(707): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
06-09 02:10:56.510: E/StrictMode(707): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
06-09 02:10:56.510: E/StrictMode(707): at java.lang.Thread.run(Thread.java:856)
06-09 02:10:56.557: W/ActivityManager(289): Unbind failed: could not find connection for android.os.BinderProxy@40e69780
06-09 02:11:02.557: W/IInputConnectionWrapper(4464): getCursorCapsMode on inactive InputConnection
06-09 02:11:03.158: E/SurfaceFlinger(37): ro.sf.lcd_density must be defined as a build property
06-09 02:11:14.797: E/WVMExtractor(40): Failed to open libwvm.so
06-09 02:11:15.637: E/WVMExtractor(40): Failed to open libwvm.so
06-09 02:11:22.179: E/SurfaceFlinger(37): ro.sf.lcd_density must be defined as a build property
06-09 02:11:23.076: W/EGL_emulation(1762): eglSurfaceAttrib not implemented
06-09 02:11:23.256: W/ActivityManager(289): Launch timeout has expired, giving up wake lock!
06-09 02:11:23.716: W/ActivityManager(289): Activity idle timeout for ActivityRecord{40fb5d68 u0 com.android.camera/.Camera}
06-09 02:11:24.146: E/SurfaceFlinger(37): ro.sf.lcd_density must be defined as a build property
06-09 02:11:24.166: E/SurfaceFlinger(37): ro.sf.lcd_density must be defined as a build property
06-09 02:11:29.237: W/InputConnectionWrapper.ICC(378): Timed out waiting on IInputContextCallback
06-09 02:11:34.387: W/AudioTrack(40): releaseBuffer() track 0x2a02af18 name=0x1 disabled, restarting
06-09 02:11:36.000: W/IInputConnectionWrapper(4464): getCursorCapsMode on inactive InputConnection
06-09 02:11:36.087: W/IInputConnectionWrapper(4464): showStatusIcon on inactive InputConnection
06-09 02:11:38.667: W/ActivityManager(289): Activity pause timeout for ActivityRecord{40fb5d68 u0 com.android.camera/.Camera}
06-09 02:11:38.950: W/AudioFlinger(40): session id 9 not found for pid 40
06-09 02:11:39.047: W/dalvikvm(4464): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
06-09 02:11:39.057: W/AudioFlinger(40): session id 10 not found for pid 40
06-09 02:11:39.377: E/AndroidRuntime(4464): FATAL EXCEPTION: main
06-09 02:11:39.377: E/AndroidRuntime(4464): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=null} to activity {irradiance.aerosolopticaldepth/irradiance.aerosolopticaldepth.MainActivity}: java.lang.NullPointerException
06-09 02:11:39.377: E/AndroidRuntime(4464): at android.app.ActivityThread.deliverResults(ActivityThread.java:3319)
06-09 02:11:39.377: E/AndroidRuntime(4464): at android.app.ActivityThread.handleSendResult(ActivityThread.java:3362)
06-09 02:11:39.377: E/AndroidRuntime(4464): at android.app.ActivityThread.access$1100(ActivityThread.java:141)
06-09 02:11:39.377: E/AndroidRuntime(4464): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1282)
06-09 02:11:39.377: E/AndroidRuntime(4464): at android.os.Handler.dispatchMessage(Handler.java:99)
06-09 02:11:39.377: E/AndroidRuntime(4464): at android.os.Looper.loop(Looper.java:137)
06-09 02:11:39.377: E/AndroidRuntime(4464): at android.app.ActivityThread.main(ActivityThread.java:5041)
06-09 02:11:39.377: E/AndroidRuntime(4464): at java.lang.reflect.Method.invokeNative(Native Method)
06-09 02:11:39.377: E/AndroidRuntime(4464): at java.lang.reflect.Method.invoke(Method.java:511)
06-09 02:11:39.377: E/AndroidRuntime(4464): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
06-09 02:11:39.377: E/AndroidRuntime(4464): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-09 02:11:39.377: E/AndroidRuntime(4464): at dalvik.system.NativeStart.main(Native Method)
06-09 02:11:39.377: E/AndroidRuntime(4464): Caused by: java.lang.NullPointerException
06-09 02:11:39.377: E/AndroidRuntime(4464): at irradiance.aerosolopticaldepth.MainActivity.onActivityResult(MainActivity.java:73)
06-09 02:11:39.377: E/AndroidRuntime(4464): at android.app.Activity.dispatchActivityResult(Activity.java:5293)
06-09 02:11:39.377: E/AndroidRuntime(4464): at android.app.ActivityThread.deliverResults(ActivityThread.java:3315)
06-09 02:11:39.377: E/AndroidRuntime(4464): ... 11 more
06-09 02:11:39.897: W/ActivityManager(289): Force finishing activity irradiance.aerosolopticaldepth/.MainActivity
06-09 02:11:40.199: E/StrictMode(1762): A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
06-09 02:11:40.199: E/StrictMode(1762): java.lang.Throwable: Explicit termination method 'release' not called
06-09 02:11:40.199: E/StrictMode(1762): at dalvik.system.CloseGuard.open(CloseGuard.java:184)
06-09 02:11:40.199: E/StrictMode(1762): at android.view.Surface.<init>(Surface.java:289)
06-09 02:11:40.199: E/StrictMode(1762): at android.view.SurfaceView.<init>(SurfaceView.java:96)
06-09 02:11:40.199: E/StrictMode(1762): at java.lang.reflect.Constructor.constructNative(Native Method)
06-09 02:11:40.199: E/StrictMode(1762): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
06-09 02:11:40.199: E/StrictMode(1762): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
06-09 02:11:40.199: E/StrictMode(1762): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:643)
06-09 02:11:40.199: E/StrictMode(1762): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
06-09 02:11:40.199: E/StrictMode(1762): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
06-09 02:11:40.199: E/StrictMode(1762): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
06-09 02:11:40.199: E/StrictMode(1762): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
06-09 02:11:40.199: E/StrictMode(1762): at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
06-09 02:11:40.199: E/StrictMode(1762): at android.view.LayoutInflater.parseInclude(LayoutInflater.java:830)
06-09 02:11:40.199: E/StrictMode(1762): at android.view.LayoutInflater.rInflate(LayoutInflater.java:736)
06-09 02:11:40.199: E/StrictMode(1762): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
06-09 02:11:40.199: E/StrictMode(1762): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
06-09 02:11:40.199: E/StrictMode(1762): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
06-09 02:11:40.199: E/StrictMode(1762): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
06-09 02:11:40.199: E/StrictMode(1762): at android.app.Activity.setContentView(Activity.java:1881)
06-09 02:11:40.199: E/StrictMode(1762): at com.android.camera.Camera.onCreate(Camera.java:1131)
06-09 02:11:40.199: E/StrictMode(1762): at android.app.Activity.performCreate(Activity.java:5104)
06-09 02:11:40.199: E/StrictMode(1762): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
06-09 02:11:40.199: E/StrictMode(1762): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
06-09 02:11:40.199: E/StrictMode(1762): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
06-09 02:11:40.199: E/StrictMode(1762): at android.app.ActivityThread.access$600(ActivityThread.java:141)
06-09 02:11:40.199: E/StrictMode(1762): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
06-09 02:11:40.199: E/StrictMode(1762): at android.os.Handler.dispatchMessage(Handler.java:99)
06-09 02:11:40.199: E/StrictMode(1762): at android.os.Looper.loop(Looper.java:137)
06-09 02:11:40.199: E/StrictMode(1762): at android.app.ActivityThread.main(ActivityThread.java:5041)
06-09 02:11:40.199: E/StrictMode(1762): at java.lang.reflect.Method.invokeNative(Native Method)
06-09 02:11:40.199: E/StrictMode(1762): at java.lang.reflect.Method.invoke(Method.java:511)
06-09 02:11:40.199: E/StrictMode(1762): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
06-09 02:11:40.199: E/StrictMode(1762): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-09 02:11:40.199: E/StrictMode(1762): at dalvik.system.NativeStart.main(Native Method)
06-09 02:11:40.647: E/StrictMode(1762): A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
06-09 02:11:40.647: E/StrictMode(1762): java.lang.Throwable: Explicit termination method 'release' not called
06-09 02:11:40.647: E/StrictMode(1762): at dalvik.system.CloseGuard.open(CloseGuard.java:184)
06-09 02:11:40.647: E/StrictMode(1762): at android.view.Surface.<init>(Surface.java:289)
06-09 02:11:40.647: E/StrictMode(1762): at android.view.SurfaceView.<init>(SurfaceView.java:97)
06-09 02:11:40.647: E/StrictMode(1762): at java.lang.reflect.Constructor.constructNative(Native Method)
06-09 02:11:40.647: E/StrictMode(1762): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
06-09 02:11:40.647: E/StrictMode(1762): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
06-09 02:11:40.647: E/StrictMode(1762): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:643)
06-09 02:11:40.647: E/StrictMode(1762): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
06-09 02:11:40.647: E/StrictMode(1762): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
06-09 02:11:40.647: E/StrictMode(1762): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
06-09 02:11:40.647: E/StrictMode(1762): at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
06-09 02:11:40.647: E/StrictMode(1762): at android.view.LayoutInflater.rInflate(LayoutInflater.java:749)
06-09 02:11:40.647: E/StrictMode(1762): at android.view.LayoutInflater.parseInclude(LayoutInflater.java:830)
06-09 02:11:40.647: E/StrictMode(1762): at android.view.LayoutInflater.rInflate(LayoutInflater.java:736)
06-09 02:11:40.647: E/StrictMode(1762): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
06-09 02:11:40.647: E/StrictMode(1762): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
06-09 02:11:40.647: E/StrictMode(1762): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
06-09 02:11:40.647: E/StrictMode(1762): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
06-09 02:11:40.647: E/StrictMode(1762): at android.app.Activity.setContentView(Activity.java:1881)
06-09 02:11:40.647: E/StrictMode(1762): at com.android.camera.Camera.onCreate(Camera.java:1131)
06-09 02:11:40.647: E/StrictMode(1762): at android.app.Activity.performCreate(Activity.java:5104)
06-09 02:11:40.647: E/StrictMode(1762): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
06-09 02:11:40.647: E/StrictMode(1762): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
06-09 02:11:40.647: E/StrictMode(1762): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
06-09 02:11:40.647: E/StrictMode(1762): at android.app.ActivityThread.access$600(ActivityThread.java:141)
06-09 02:11:40.647: E/StrictMode(1762): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
06-09 02:11:40.647: E/StrictMode(1762): at android.os.Handler.dispatchMessage(Handler.java:99)
06-09 02:11:40.647: E/StrictMode(1762): at android.os.Looper.loop(Looper.java:137)
06-09 02:11:40.647: E/StrictMode(1762): at android.app.ActivityThread.main(ActivityThread.java:5041)
06-09 02:11:40.647: E/StrictMode(1762): at java.lang.reflect.Method.invokeNative(Native Method)
06-09 02:11:40.647: E/StrictMode(1762): at java.lang.reflect.Method.invoke(Method.java:511)
06-09 02:11:40.647: E/StrictMode(1762): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
06-09 02:11:40.647: E/StrictMode(1762): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-09 02:11:40.647: E/StrictMode(1762): at dalvik.system.NativeStart.main(Native Method)
06-09 02:11:42.377: W/ActivityManager(289): Activity pause timeout for ActivityRecord{40ec7900 u0 irradiance.aerosolopticaldepth/.MainActivity}
06-09 02:11:43.637: E/SurfaceFlinger(37): ro.sf.lcd_density must be defined as a build property
06-09 02:11:47.517: W/ActivityManager(289): Unable to start service Intent { act=com.android.email.ACCOUNT_INTENT } U=0: not found
06-09 02:11:48.175: W/ActivityManager(289): Launch timeout has expired, giving up wake lock!
06-09 02:11:48.647: W/InputDispatcher(289): channel '40fc3848 irradiance.aerosolopticaldepth/irradiance.aerosolopticaldepth.MainActivity (server)' ~ Consumer closed input channel or an error occurred. events=0x9
06-09 02:11:48.647: E/InputDispatcher(289): channel '40fc3848 irradiance.aerosolopticaldepth/irradiance.aerosolopticaldepth.MainActivity (server)' ~ Channel is unrecoverably broken and will be disposed!
06-09 02:11:48.767: W/InputDispatcher(289): Attempted to unregister already unregistered input channel '40fc3848 irradiance.aerosolopticaldepth/irradiance.aerosolopticaldepth.MainActivity (server)'
06-09 02:11:49.668: W/ActivityManager(289): Unable to start service Intent { act=com.android.email.ACCOUNT_INTENT } U=0: not found
06-09 02:11:50.137: E/ActivityThread(707): Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d0b180 that was originally bound here
06-09 02:11:50.137: E/ActivityThread(707): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d0b180 that was originally bound here
06-09 02:11:50.137: E/ActivityThread(707): at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
06-09 02:11:50.137: E/ActivityThread(707): at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
06-09 02:11:50.137: E/ActivityThread(707): at android.app.ContextImpl.bindService(ContextImpl.java:1418)
06-09 02:11:50.137: E/ActivityThread(707): at android.app.ContextImpl.bindService(ContextImpl.java:1407)
06-09 02:11:50.137: E/ActivityThread(707): at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
06-09 02:11:50.137: E/ActivityThread(707): at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
06-09 02:11:50.137: E/ActivityThread(707): at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
06-09 02:11:50.137: E/ActivityThread(707): at com.android.emailcommon.service.AccountServiceProxy.getDeviceId(AccountServiceProxy.java:116)
06-09 02:11:50.137: E/ActivityThread(707): at com.android.exchange.ExchangeService.getDeviceId(ExchangeService.java:1249)
06-09 02:11:50.137: E/ActivityThread(707): at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1856)
06-09 02:11:50.137: E/ActivityThread(707): at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
06-09 02:11:50.137: E/ActivityThread(707): at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
06-09 02:11:50.137: E/ActivityThread(707): at android.os.AsyncTask$2.call(AsyncTask.java:287)
06-09 02:11:50.137: E/ActivityThread(707): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
06-09 02:11:50.137: E/ActivityThread(707): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
06-09 02:11:50.137: E/ActivityThread(707): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
06-09 02:11:50.137: E/ActivityThread(707): at java.lang.Thread.run(Thread.java:856)
06-09 02:11:50.387: E/SurfaceFlinger(37): ro.sf.lcd_density must be defined as a build property
06-09 02:11:50.650: E/StrictMode(707): null
06-09 02:11:50.650: E/StrictMode(707): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d0b180 that was originally bound here
06-09 02:11:50.650: E/StrictMode(707): at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
06-09 02:11:50.650: E/StrictMode(707): at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
06-09 02:11:50.650: E/StrictMode(707): at android.app.ContextImpl.bindService(ContextImpl.java:1418)
06-09 02:11:50.650: E/StrictMode(707): at android.app.ContextImpl.bindService(ContextImpl.java:1407)
06-09 02:11:50.650: E/StrictMode(707): at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
06-09 02:11:50.650: E/StrictMode(707): at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
06-09 02:11:50.650: E/StrictMode(707): at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
06-09 02:11:50.650: E/StrictMode(707): at com.android.emailcommon.service.AccountServiceProxy.getDeviceId(AccountServiceProxy.java:116)
06-09 02:11:50.650: E/StrictMode(707): at com.android.exchange.ExchangeService.getDeviceId(ExchangeService.java:1249)
06-09 02:11:50.650: E/StrictMode(707): at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1856)
06-09 02:11:50.650: E/StrictMode(707): at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
06-09 02:11:50.650: E/StrictMode(707): at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
06-09 02:11:50.650: E/StrictMode(707): at android.os.AsyncTask$2.call(AsyncTask.java:287)
06-09 02:11:50.650: E/StrictMode(707): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
06-09 02:11:50.650: E/StrictMode(707): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
06-09 02:11:50.650: E/StrictMode(707): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
06-09 02:11:50.650: E/StrictMode(707): at java.lang.Thread.run(Thread.java:856)
06-09 02:11:50.677: W/ActivityManager(289): Unbind failed: could not find connection for android.os.BinderProxy@41150178
06-09 02:11:50.927: W/EGL_emulation(407): eglSurfaceAttrib not implemented
06-09 02:11:51.347: E/ActivityThread(707): Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d0a990 that was originally bound here
06-09 02:11:51.347: E/ActivityThread(707): android.app.ServiceConnectionLeaked: Service com.android.exchange.ExchangeService has leaked ServiceConnection com.android.emailcommon.service.ServiceProxy$ProxyConnection@40d0a990 that was originally bound here
06-09 02:11:51.347: E/ActivityThread(707): at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:969)
06-09 02:11:51.347: E/ActivityThread(707): at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:863)
06-09 02:11:51.347: E/ActivityThread(707): at android.app.ContextImpl.bindService(ContextImpl.java:1418)
06-09 02:11:51.347: E/ActivityThread(707): at android.app.ContextImpl.bindService(ContextImpl.java:1407)
06-09 02:11:51.347: E/ActivityThread(707): at android.content.ContextWrapper.bindService(ContextWrapper.java:473)
06-09 02:11:51.347: E/ActivityThread(707): at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:157)
06-09 02:11:51.347: E/ActivityThread(707): at com.android.emailcommon.service.ServiceProxy.setTask(ServiceProxy.java:145)
06-09 02:11:51.347: E/ActivityThread(707): at com.android.emailcommon.service.ServiceProxy.test(ServiceProxy.java:191)
06-09 02:11:51.347: E/ActivityThread(707): at com.android.exchange.ExchangeService$7.run(ExchangeService.java:1850)
06-09 02:11:51.347: E/ActivityThread(707): at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:551)
06-09 02:11:51.347: E/ActivityThread(707): at com.android.emailcommon.utility.Utility$2.doInBackground(Utility.java:549)
06-09 02:11:51.347: E/ActivityThread(707): at android.os.AsyncTask$2.call(AsyncTask.java:287)
06-09 02:11:51.347: E/ActivityThread(707): at java.util.concurrent.FutureTask.run(FutureTask.java:234)
06-09 02:11:51.347: E/ActivityThread(707): at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1080)
06-09 02:11:51.347: E/ActivityThread(707): at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:573)
06-09 02:11:51.347: E/ActivityThread(707): at java.lang.Thread.run(Thread.java:856)
06-09 02:11:52.498: W/ActivityManager(289): Activity idle timeout for ActivityRecord{40f7a298 u0 com.android.launcher/com.android.launcher2.Launcher}
仍然没有运气,我已经改变了照相机意图代码:
@Override
public void onClick(View v) {
String _path = Environment.getExternalStorageDirectory().getAbsolutePath() + "sunpic.jpg";
File file = new File(_path);
//Uri fileUri = Uri.fromFile(file);
Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
intent.putExtra(MediaStore.EXTRA_OUTPUT, file);
//File file = new File(Environment.getExternalStorageDirectory().getPath());
intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(file));
startActivityForResult(intent, CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE);
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//super.onActivityResult(requestCode, resultCode, data);
if(requestCode == CAPTURE_IMAGE_ACTIVITY_REQUEST_CODE && resultCode == RESULT_OK) {
//Uri file = data.getData();
FileInputStream is;
try {
is = new FileInputStream("mnt/sdcard/sunpic.jpg");
Bitmap bmp = BitmapFactory.decodeStream(is);
//Bitmap bmp = android.provider.MediaStore.Images.Media.getBitmap(this.getContentResolver(), file);
//Bitmap bmp = (Bitmap) data.getExtras().get("data");
bmp.getPixels(pixels, 0, bmp.getWidth(), 0, 0, bmp.getWidth(), bmp.getHeight());
其余部分与我原来发布的内容完全相同。
logcat是空的,只要我在相机上拍照,它就会冻结。
我之前尝试的不包括
FileInputStream is;
try {
is = new FileInputStream("mnt/sdcard/sunpic.jpg");
并有下一行
Bitmap bmp = BitmapFactory.decodeStream("sunpic.jpg");
但是,这始终吐出NullPointer错误,我真的不明白为什么,尽管阅读了许多其他线程/其他网络资源。
链接地址: http://www.djcxy.com/p/14045.html上一篇: camera intent and priority queue in Android
下一篇: Tried several fixes: Heroku/Rails 4 Assets Precompile Error