相机在WebView中不开放 [英] Camera not opening in WebView

查看:150
本文介绍了相机在WebView中不开放的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我在的WebView 相机工作。我实现了一些 HTML code从资产的WebView该文件负载我的 HTML 文件包含一个按钮上传图像到服务器。图像是从画廊本身的选择和相机拍照。但是当我用相机尝试它不是开放。我不知道为什么?另外,我在补充所需摄像机的权限我的的manifest.xml

请一些有一点我在哪里,我错了?

的Manifest.xml

 <?XML版本=1.0编码=UTF-8&GT?;
<清单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
包=com.example.maptest
安卓版code =1
机器人:=的versionName1.0><许可
    机器人:名字=com.example.maptest.permission.MAPS_RECEIVE
    安卓的ProtectionLevel =签名/><使用许可权的android:NAME =com.example.maptest.permission.MAPS_RECEIVE/>
<! - 从谷歌地图图书馆/ AndroidManifest.xml中复制。 - >
<用途-SDK
    安卓的minSdkVersion =14
    机器人:targetSdkVersion =16/><使用许可权的android:NAME =android.permission.READ_SMS/>
<使用许可权的android:NAME =android.permission.ACCESS_NETWORK_STATE/>
<使用许可权的android:NAME =android.permission.INTERNET对/>
<使用许可权的android:NAME =android.permission.WRITE_EXTERNAL_STORAG​​E/>
<使用许可权的android:NAME =android.permission.INTERNET对/>
<使用许可权的android:NAME =android.permission.CAMERA/>
<使用许可权的android:NAME =android.permission.WRITE_EXTERNAL_STORAG​​E/><! - 我的位置 - >
<使用许可权的android:NAME =android.permission.ACCESS_COARSE_LOCATION/>
<使用许可权的android:NAME =android.permission.ACCESS_FINE_LOCATION/>
<使用许可权的android:NAME =com.google.android.providers.gsf.permission.READ_GSERVICES/>
<! - 缓存外部存储。 - >
<! - Maps API需要OpenGL ES 2.0的。 - >
<用途特征
    机器人:glEsVersion =0x00020000
    机器人:要求=真/><应用
    机器人:可调试=真
    机器人:图标=@绘制/ sms_lg
    机器人:标签=短信读本>
    &所述;元数据
        机器人:名字=com.google.android.maps.v2.API_KEY
        机器人:值=映射键/>    <活动
        机器人:WebView2NAME =
        机器人:标签=@字符串/ APP_NAME>
        &所述;意图滤光器>
            <作用机器人:名字=android.intent.action.MAIN/>            <类机器人:名字=android.intent.category.LAUNCHER/>
        &所述; /意图滤光器>
    < /活性GT;
    <活动机器人:名字=BasicMapActivity2>
    < /活性GT;
    &所述;元数据
        机器人:名字=com.google.android.gms.version
        机器人:值=@整数/ GOOGLE_PLAY_SERVICES_VERSION/>
< /用途>< /清单>


解决方案

我收到了你的问题,我认为你需要添加<使用特征> 相机,如:

 <使用特征
    机器人:名字=android.hardware.camera
    机器人:要求=真/>

这是becoz请求许可授予相应的硬件和软件应用程序访问,同时宣布使用的特点您的应用程序可确保正确的设备兼容。

试试这个,给我这样的反馈。欲了解更多信息,请访问 http://developer.android.com/指南/主题/清单/使用-功能element.html

hi i have to work in WebView with Camera. I am implemented some HTML code that file load from the Assets in WebView and my HTML file contains a Button for uploading image into server. Images are selected from Gallery itself and taking photo from camera. but when i try with camera it's not opening. I dont know why? also, i added required camera permission in my manifest.xml.

please some one point me where i am going wrong?

Manifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.maptest"
android:versionCode="1"
android:versionName="1.0" >

<permission
    android:name="com.example.maptest.permission.MAPS_RECEIVE"
    android:protectionLevel="signature" />

<uses-permission android:name="com.example.maptest.permission.MAPS_RECEIVE" />
<!-- Copied from Google Maps Library/AndroidManifest.xml. -->
<uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="16" />

<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />


<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

<!-- My Location -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
<!-- External storage for caching. -->
<!-- Maps API needs OpenGL ES 2.0. -->
<uses-feature
    android:glEsVersion="0x00020000"
    android:required="true" />

<application
    android:debuggable="true"
    android:icon="@drawable/sms_lg"
    android:label="SMS Reader" >
    <meta-data
        android:name="com.google.android.maps.v2.API_KEY"
        android:value="mapkey" />

    <activity
        android:name=".WebView2"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name="BasicMapActivity2" >
    </activity>
    <meta-data
        android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version" />
</application>

</manifest>

解决方案

I got your issue i think you need to add <uses-feature> for camera like:

<uses-feature
    android:name="android.hardware.camera"
    android:required="true" />

It's becoz requesting the permission grants your application access to the appropriate hardware and software, while declaring the features used by your application ensures proper device compatibility.

Try this and give me feedback on this. For more information go to http://developer.android.com/guide/topics/manifest/uses-feature-element.html

这篇关于相机在WebView中不开放的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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