Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/195.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android:请求照片时出错?_Android_Get_Uri_Android Intent_Photos - Fatal编程技术网

Android:请求照片时出错?

Android:请求照片时出错?,android,get,uri,android-intent,photos,Android,Get,Uri,Android Intent,Photos,我的应用程序遇到了一个我以前没有遇到的问题。我试图做的是允许用户使用intent从设备上拍摄照片。然后将该照片返回到调用活动,然后在图像视图中显示(目前…)。问题是昨天一切都对我有效,而今天(…代码没有改变任何东西…)似乎什么都没做。看起来这个应用程序几乎是“挂起”的。不知道如何解决这个问题,甚至不知道解决问题的根本原因。如果任何人有任何建议,请发布,以下是代码: //---Pressing this button will allow for user to choose what photo

我的应用程序遇到了一个我以前没有遇到的问题。我试图做的是允许用户使用intent从设备上拍摄照片。然后将该照片返回到调用活动,然后在图像视图中显示(目前…)。问题是昨天一切都对我有效,而今天(…代码没有改变任何东西…)似乎什么都没做。看起来这个应用程序几乎是“挂起”的。不知道如何解决这个问题,甚至不知道解决问题的根本原因。如果任何人有任何建议,请发布,以下是代码:

//---Pressing this button will allow for user to choose what photo should return---
    Button b2 = (Button) findViewById(R.id.btn_getPhotos);
    b2.setOnClickListener(new OnClickListener()
    {

        public void onClick(View arg0)
        {
            Intent i = new Intent(Intent.ACTION_GET_CONTENT);
            //Intent i = new Intent(Intent.ACTION_PICK);
            i.setType("image/*");

            //**Keep in mind after calling the StartActivityForResult() it seems to hang...**
            startActivityForResult(i, PIC_REQUEST);

        }

    });
以下是OnActivityResult():

最后但并非最不重要的是警告/错误日志:

11-09 10:07:47.060: WARN/InputManagerService(142): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@407d13a8
11-09 10:07:56.330: WARN/ActivityThread(3957): Application king.chad.SDE is waiting for the debugger on port 8100...
11-09 10:08:06.250: WARN/ActivityManager(142): Launch timeout has expired, giving up wake lock!
11-09 10:08:06.320: WARN/ActivityManager(142): Activity idle timeout for ActivityRecord{40939988 king.chad.SDE/.MainActivity}
我想说,我的问题在日志的这一部分(基于我研究过的其他论坛相关问题…),但我不确定:

11-09 10:08:23.090: WARN/InputManagerService(142): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@407f37e0 (uid=10022 pid=238)
11-09 10:08:45.890: WARN/InputManagerService(142): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@40ce5140
卸载的应用程序,重新安装,添加了标签,第二次运行时出现错误日志:

11-09 10:23:59.690: WARN/ActivityManager(142): No content provider found for: 
11-09 10:23:59.700: WARN/PackageParser(142): Unknown element under <manifest>: uses-library at /data/app/vmdl1692687349.tmp Binary XML file line #8
11-09 10:23:59.700: WARN/ActivityManager(142): No content provider found for: 
11-09 10:24:00.730: WARN/ResourceType(273): getEntry failing because entryIndex 1041 is beyond type entryCount 185
11-09 10:24:00.760: WARN/ResourceType(273): Failure getting entry for 0x7f020411 (t=1 e=1041) in package 0 (error -2147483647)
11-09 10:24:00.760: WARN/ResourceType(273): getEntry failing because entryIndex 1042 is beyond type entryCount 185
11-09 10:24:00.760: WARN/ResourceType(273): Failure getting entry for 0x7f020412 (t=1 e=1042) in package 0 (error -2147483647)
11-09 10:24:00.760: WARN/ResourceType(273): getEntry failing because entryIndex 1043 is beyond type entryCount 185
11-09 10:24:00.760: WARN/ResourceType(273): Failure getting entry for 0x7f020413 (t=1 e=1043) in package 0 (error -2147483647)
11-09 10:24:00.760: WARN/ResourceType(273): getEntry failing because entryIndex 1420 is beyond type entryCount 185
11-09 10:24:00.760: WARN/ResourceType(273): Failure getting entry for 0x7f02058c (t=1 e=1420) in package 0 (error -2147483647)
11-09 10:24:00.770: WARN/ResourceType(273): getEntry failing because entryIndex 223 is beyond type entryCount 185
11-09 10:24:00.770: WARN/ResourceType(273): Failure getting entry for 0x7f0200df (t=1 e=223) in package 0 (error -2147483647)
11-09 10:24:01.500: WARN/ActivityThread(5952): Application king.chad.SDE is waiting for the debugger on port 8100...
11-09 10:24:11.330: WARN/ActivityManager(142): Launch timeout has expired, giving up wake lock!
11-09 10:24:11.470: WARN/ActivityManager(142): Activity idle timeout for ActivityRecord{408a9dc8 king.chad.SDE/.MainActivity}
11-09 10:24:14.510: WARN/InputManagerService(142): Starting input on non-focused client com.android.internal.view.IInputMethodClient$Stub$Proxy@407f37e0 (uid=10022 pid=238)
11-09 10:24:53.730: WARN/InputManagerService(142): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@4090b358
11-09 10:23:59.690:警告/ActivityManager(142):找不到以下内容的内容提供程序:
11-09 10:23:59.700:WARN/PackageParser(142):下的未知元素:uses library at/data/app/vmdl1692687349.tmp二进制XML文件行#8
11-09 10:23:59.700:警告/ActivityManager(142):找不到以下内容的内容提供程序:
11-09 10:24:00.730:警告/资源类型(273):getEntry失败,因为entryIndex 1041超出了entryCount 185类型
11-09 10:24:00.760:警告/资源类型(273):获取包0中0x7f020411(t=1 e=1041)的条目失败(错误-2147483647)
11-09 10:24:00.760:警告/资源类型(273):getEntry失败,因为entryIndex 1042超出了entryCount 185类型
11-09 10:24:00.760:警告/资源类型(273):获取包0中0x7f020412(t=1 e=1042)的条目失败(错误-2147483647)
11-09 10:24:00.760:警告/资源类型(273):getEntry失败,因为entryIndex 1043超出了entryCount 185类型
11-09 10:24:00.760:警告/资源类型(273):获取包0中0x7f020413(t=1 e=1043)的条目失败(错误-2147483647)
11-09 10:24:00.760:警告/资源类型(273):getEntry失败,因为entryIndex 1420超出类型entryCount 185
11-09 10:24:00.760:警告/资源类型(273):获取包0中0x7f02058c(t=1 e=1420)的条目失败(错误-2147483647)
11-09 10:24:00.770:警告/资源类型(273):getEntry失败,因为entryIndex 223超出类型entryCount 185
11-09 10:24:00.770:警告/资源类型(273):获取包0中0x7f0200df(t=1 e=223)的条目失败(错误-2147483647)
11-09 10:24:01.500:警告/活动线程(5952):应用程序king.chad.SDE正在端口8100上等待调试器。。。
11-09 10:24:11.330:警告/活动管理器(142):启动超时已过期,放弃唤醒锁定!
11-09 10:24:11.470:WARN/ActivityManager(142):ActivityRecord{408a9dc8 king.chad.SDE/.MainActivity}的活动空闲超时
11-09 10:24:14.510:WARN/InputManagerService(142):在非焦点客户端com.android.internal.view.IInputMethodClient$Stub上开始输入$Proxy@407f37e0(uid=10022 pid=238)
11-09 10:24:53.730:WARN/InputManagerService(142):窗口已聚焦,忽略:com.android.internal.view.IInputMethodClient$Stub的聚焦增益$Proxy@4090b358

嗯,我不确定上面的代码为什么不起作用,但我确实找到了解决方法。经过大量阅读和搜索,我发现这个问题实际上可能与我的代码无关,而是与我使用的设备有关。我最终通过更改以下内容来更改startActivityForResult()方法:

startActivityForResult(i, PIC_REQUEST);
……为此:

startActivityForResult(Intent.createChooser(i, "Select a photo"), PIC_REQUEST);
…现在一切都好了。希望这能帮助你们中可能遇到同样问题的任何人

startActivityForResult(Intent.createChooser(i, "Select a photo"), PIC_REQUEST);