为什么我使用beαuty相机blus相机的美化总是显示文件不存在哪里出问题了呢?该怎么做呢?

sonyα7Ⅱ相机显示屏不显示怎么解决_百度知道
sonyα7Ⅱ相机显示屏不显示怎么解决
我有更好的答案
个人经验,找下有没有 外屏和内屏切换键,按下;如果没有,可能能拍,从电脑能看,就是屏背光或者主板问题;不能拍,可能是不开机,不显示字符,主板问题。需要送修了。
采纳率:67%
引用cn#BaaGVGaBkp的回答:个人经验,找下有没有 外屏和内屏切换键,按下;如果没有,可能能拍,从电脑能看,就是屏背光或者主板问题;不能拍,可能是不开机,不显示字符,主板问题。需要送修了。
在相机的取景器上方有一发射红外线的目镜传感器,其作用是当你用眼靠近或离开取景器时实行取景器和显示屏显示的切换。可检查一下目镜传感器上是否有灰尘或污物沾染,如有擦去或就可解决。
1条折叠回答
为您推荐:
其他类似问题
显示屏的相关知识
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。ZBrush为什么镜像出问题?_百度知道
ZBrush为什么镜像出问题?
This function can not be applied to a mesh with multiple subdivision levels(这个功能能不适用于一个网孔同多种细分水平)。 要怎么解决?
我镜像牙齿就行,镜像别的就行。
This function can not be applied to a mesh with multiple subdivision levels(这个功能能不适用于一个网孔同多种细分水平)。 要怎么解决?
我镜像牙齿就不行!!!!镜像别的就行。
我有更好的答案
我试了把物体Del Lower,没有细分级别的物体就能镜像了。挺不爽的,我记得以前有细分级别的物体也能镜像的。
采纳率:100%
重新整理一下物体在空间里的坐标轴,或者导出MAYA 或MAX
确定一下中心轴的位置
坐标肯定没问题。牙齿我是用ZB里自带的 3D模型(球) 雕刻的,
删除低级细分就行了 Geometry-Del Lower
1条折叠回答
为您推荐:
其他类似问题
zbrush的相关知识
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。memory stick pro duo被我给格式化了,插到相机里显示没差好,是不是里边缺原始文件了?怎么恢复?_百度知道
memory stick pro duo被我给格式化了,插到相机里显示没差好,是不是里边缺原始文件了?怎么恢复?
我有更好的答案
不能用WINDOWS格式化的,现在把卡放在相机里,用相机里面的格式化功能格式化一次。就可以了。
采纳率:32%
为您推荐:
其他类似问题
您可能关注的内容
格式化的相关知识
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。努力加载中,稍等...
暂无新消息
努力加载中,稍等...
已无更多消息...
这些人最近关注了你
努力加载中,稍等...
已无更多消息
努力加载中,稍等...
已无更多消息
& 使用多个Unity的摄像机-为什么这个功能可能非常重要?
Using Multiple Unity Cameras – Why This May Be Important?
征集热心朋友翻译文章,奖励规则:每100汉字奖励10QB,30天内互动奖励0 - 50QB.
翻译请求:申请翻译 预计完成翻译
译者拥有两年unity使用经验
该文章来自用户转载
Using Multiple Unity Cameras – Why This May Be Important?, , From what I observe, many Unity users do not grasp the concept of using multiple Unitycameras on a single scene. “If I want to look from only one perspective, why do I need more than one camera?”. Saying that it makes perfect sense when more than one camera captures the scene from the same perspective makes it even more confusing. So why even bother? The reason is somewhat complex, but it’s really worth learning. It will help you create great visual effects, that are hard to accomplish with the use of only one camera, in an easy way.What is the Unity camera?Before we can continue, you have to understand what Unity
actually is. When Unity renders the scene it needs much of important information to be set up, but let’s simplify that list to make it easier to understand. Let’s consider:List of objects to renderCamera’s perspective (position, rotation, scale, field of view, clipping etc.)If you’re already experienced in that matter you might’ve noticed that I’m not speaking about matrices. Let’s just ignore math-related stuff for now.List of objects to render is a list of all objects on the scene, right? Wrong! Each camera renders only the objects visible to it (field of view, frustum culling) and those on the layer which actually seen by the camera (Culling Mask.)Culling Mask can be set to Everything, or you may set which of the layers should be seen. This is one thing what layers are for.This camera sees everything.This camera sees only the Default layer (ground) and the Red layer (red sphere).The conclusion is that different cameras can render different objects. This is important information even if you don’t know yet how to use it in practice. It also means that adding second camera will not re-draw your scene two times. Only objects visible to the second camera will be rendered. Knowing this having multiple cameras rendering different layers will result in similar efficiency as rendering all these layers using only one camera.Let’s then answer the main question: Camera is an instruction to render specific list of objects from given perspective.What camera renders?Wait, haven’t we just answered that question?! Well… not exactly. There’s a visible and an invisible part. What you can see is a result image (let’s call it color buffer). And of course there’s a thing that you cannot see. This thing is called a
(called alsoz-buffer).Depth buffer can be easily described as a game screen sized gray-scale image, every pixel of which represents how close that pixel is to the camera (to be honest this is not 100% true but let’s not think of more complicated cases now.) It is used by the GPU to decide whether to-be-rendered pixel should be processed or rejected from rendering. As a result, pixels that are obstructed by other pixels are not going to be visible (just like in the real world.)Camera order and clearingBefore rendering anything into color buffer and depth buffer, camera can clear both buffers or only the depth buffer. Did you notice that the default Unity 5 scene camera clears buffers to Skybox?There are some more options there:Skybox replaces color buffer with your skybox and completely clear depth bufferSolid color does the same, but color buffer becomes solid colorDepth only leaves color buffer at is, but your depth buffer becomes clearDon’t Clear doesn’t clear anything.What will happen if we will try to set the default camera Clear Flags to Don’t Clear? Well, the effect may be interesting (I moved the camera a little after entering the Play mode).It looks like our sphere duplicated itself so many times, that it turned into some kind of wired, rounded pipes thing. Besides that there’s still one red sphere on the scene (note that Blue layer is still not visible to the camera), the game scene image looks valid. There are no graphical artifacts of any kind. Yet we managed to create an effect of many duplicated objects with only one object.This happened because color buffer was not cleared between frames (colors rendered previously were transferred to the next frame), also the depth buffer. Depth buffer remembered that something has been rendered and it was keeping this information when Unity tried to render another frame. When sphere was about to be rendered behind already rendered sphere image, invisible pixels were discarded. The same thing applies when there are many objects on the scene rendering one after another.If you still don’t understand what just happened, please stop reading now and try doing it yourself! Make a new scene, add an object, set camera Clear Flags to Don’t Clear and move either your object or your camera.What is it good for?I assume that you don’t want this kind of effect in your game, so what’s the clearing good for? Let’s now try to create two cameras.Blue CameraClear Flags: SkyboxCulling Mask: Default, BlueDepth: 0What Blue Camera sees.Red CameraClear Flags: Don’t ClearCulling Mask: RedDepth: 1What Red Camera sees.There’s one new parameter: Depth. Depth defines the order of rendering of the cameras. Camera with lower depth will be rendered before the camera with a higher depth.Let’s see how Unity will render this scene step by step (again not 100% accurate, but it’s only to understand the process):(Blue Camera context)Color buffer is cleared to SkyboxDepth buffer is clearedPlane (Default layer) and blue sphere (Blue layer) are rendered(Rex Camera context)Nothing is clearedRed sphere (Red layer) is renderedAs the result you get a scene that looks exactly like rendered using a single camera:So why bother? Let’s try one thing. Let’s switch Red Camera Clear Flags from Don’t Clear to Depth only:Whoa, do you see that? Since depth buffer has been cleared, red sphere doesn’t know that its pixels are obstructed, so it’s rendering like there’s nothing on the scene. That means that clearing the depth buffer brings rendered objects to the front. This may be super-useful when you’d like to render 3D UI elements.In Skyrim you can see inventory items as 3D objects. These are rendered correctly even if background object appears closer to the camera.Another interesting option is applying camera effects only to specific layers. Let’s try to apply blur to the Blue Camera, just like on the screenshot below:Let’s now switch
Red Camera Clear Flags back to Don’t Clear and apply a different effect to the Blue Camera: Grayscale.Finally, keep in mind that if you want to move the camera, you may want to move all cameras at once (that’s why keeping all the cameras as a child of one game object is quite common.) But moving only one camera may be somewhat desired…
使用多个Unity的摄像机-为什么这个功能可能非常重要?
版权所有,禁止匿名转载;禁止商业使用;禁止个人使用。
译者:张大伟(卡卡是我)
审校:崔国军(飞扬971) 根据我的观察,很多Unity 用户统并没有掌握该如何在一个单一场景中使用多个Unity的摄像机,他们对这个概念缺乏一些了解。 “如果我只是想从一个角度看这个场景,为什么我需要使用多个摄像机?”这个问题初听上去很有道理,当多个摄像机从同一个角度捕捉场景的时候会使得它更加混乱。那为什么还要在同一个场景中同一个方向上使用多个摄像机?原因是有些复杂,但是在同一个场景中同一个方向上使用多个摄像机这个事情确实值得我们学习。它会帮助你用一种很容易的方式来创造非常震撼的视觉效果,而这些效果如果只使用一个摄像机就很难完成。 什么是Unity中的摄像机?在我们继续讨论这个话题之前, 你必须明白Unity的摄像机到底是什么。当Unity渲染场景的时候,它需要大量的重要信息被设置好,但是让我们简化下这些需要提前设置好的重要信息的列表使其更加容易理解。我们要考虑的重要信息有:·要渲染的物体的列表·摄像机的视角(以及摄像机的位置、旋转、缩放、视野、裁剪等等)如果你已经对这个问题有了一些经验。你可能已经注意到我并不是在谈论矩阵。让我们现在先忽略数学相关的东西。要渲染的物体的列表就是场景中的所有物体,是不是这样?错了!每个摄像机只会渲染那些对它来说是可见的物体(依据视野、视野锥体剔除等等)以及那些实际在指定摄像机可见的层上的物体。剔除遮罩使用层有选择地渲染一组对象。有关使用层的信息可以在官方文档找到。通常比较好的做法是,是把用户界面放到不同的层,然后用一个独立相机单独渲染UI层。为了使UI显示在其他相机视角的顶部,你还需要设置清除标记为“只清除深度缓冲区“,并确保UI相机的深度比其他相机高。剔除遮罩可以被设置成任何东西,或者你可以设置哪些层应该被看到。这个属性用来选择性的渲染部分场景。如果游戏物体的层遮罩与摄像机的剔除遮罩进行相交操作后结果为0,那么这个游戏物体对于这个摄像机来说是不可见的。如果按照这个图设置的话,这个摄像机现在可以看到所有的物体。这台摄像机只能看到默认层(地面那一层)和标记为红色的层(红球所在的层)里面的物体。所得出的结论是不同的摄像机可以渲染不同的对象。而这是一条你现在还不知道该如何在实践中使用的重要信息。这也意味着,在场景中添加第二个摄像机不会导致重新绘制场景两次。只有对于第二个摄像机来说是可见的物体才会被渲染出来。有多个不同的摄像机分别渲染不同的层和用一个摄像机来渲染所有的层的效率是完全一样的,请认识到这一点。那么,接下来让我们回答下主要的问题,也就是Unity的摄像机到底是什么。摄像机是一种设备,可以在给定的视角来渲染一组给定的物体。 摄像机到底在渲染什么?等一下,我们不是刚回答了这个问题么?嗯......不完全是。场景中的物体分为可见和不可见的部分。你能看到的是最后作为结果输出的图像(让我们称它为颜色缓冲区)。当然还有一些东西是你看不到,这个看不到的东西被称为深度缓冲区(也被称为z buffer)。深度缓冲区可以很容易的被描述为一个游戏屏幕大小的灰度图像,这个图像中的每个像素都代表着这个像素到摄像机到底有多远(实话实说这个解释不是100%正确的,但是我们认为现在不应该为了追求准确性而把这个概念解释的过于复杂)。深度缓冲区是由显卡的GPU来使用的,用来决定要被渲染的像素是否应该被处理还是应该从渲染中移除。结果就是,会被其他像素遮挡住的像素不会是可见的。这个机制就跟现实世界中的机制是完全一样的,由于遮挡关系,我们看到不透明物体后面的内容,这个机制在计算机图形学中有个专门的名字叫画面算法。画家算法也叫作优先填充,它是中处理的一种解决方法。当将三维场景投影到二维平面的时候,需要确定哪些是可见的,哪些是不可见的。“画家算法”表示头脑简单的画家首先绘制距离较远的场景,然后用绘制距离较近的场景覆盖较远的部分。画家算法首先将场景中的多边形根据深度进行排序,然后按照顺序进行描绘。这种方法通常会将不可见的部分覆盖,这样就可以解决可见性问题。在有些场合下,画家算法可能无法解决可见性问题。在这个例子中,多边形 A、B、C 互相重叠,我们无法确定哪一个多边形在上面,哪一个在下面,我们也无法确定两个多边形什么时候在三维空间中交叉。在这种情况下必须用一些方法对这些多边形进行切分、排序。1972年提出的就是切分类似多边形的一种方法,在领域人们已经提出了许许多多的解决方法。一些基本的画家算法实现方法也可能效率很低,因为这将使得系统将可见多边形集合中的每个点都进行,而没有考虑这些多变性在最终场景中可能被其它部分遮挡。这也就是说,对于细致的场景来说,画家算法可能会过度地消耗计算机资源。人们有时候也使用逆向画家算法进行处理,这种算法首先绘制距离观察者较近的物体,已经进行绘制的部分不再进行其它的绘制过程。在计算机图形系统中,这种方法由于无需根据光照、纹理等参数计算被较近物体遮挡的远处物体的颜色,所以效率非常高。但是,这种方法也有许多与普通画家算法同样的问题。画家算法的这些缺陷导致了技术的发展,深度缓冲技术可以看作是画家算法的一个发展,它根据逐个像素的信息解决深度冲突的问题,并且抛弃了对于深度渲染顺序的依赖。即使在这样的系统中,有时也使用画家算法的变体。由于深度缓冲实现通常是基于硬件中的固定精度深度缓冲寄存器,因此舍入误差就会带来一些显示问题,即在多边形连接的地方会出现重叠或者间隙。为了避免这种问题,一些图形处理引擎使用了“过度渲染”的方法,即根据画家算法的顺序绘制两个多边形中受影响的边界。这也就是说有些像素如同在画家算法中那样实际上绘制了两次,但是由于图像中只有很少的一部分才做这样的处理,因此对于性能的影响很小。 摄像机的顺序和清理屏幕在渲染场景的内容到颜色缓冲区和深度缓冲区之前,摄像机可以清除两个缓冲区的内容或者单独清理深度缓冲区的内容。你有没有注意到,默认情况下Unity5场景摄像机会将颜色缓冲区的内容清除到天空盒的缓冲区里里面去?每个摄像机在渲染时会存储颜色和深度信息。屏幕的未绘制部分是空的,默认情况下会显示天空盒。当你使用多个摄像机的时候,每一个摄像机都将自己的颜色和深度信息存储在缓冲区中,还将积累大量的每个摄像机的渲染数据。当场景中的任何特定摄像机进行渲染时,你可以设定清除标记以清除缓冲区信息的不同集合。可以通过下面四个选项之一来完成:关于清除标记的话,这里还有一些更多的选择:l“迁移到天空盒缓冲区并清除” 这是默认设置。在屏幕上空的部分将显示当前相机的天空盒。如果当前相机没有设置天空盒,它会默认使用渲染设置(在Edit-&Render Settings里)中选择的天空盒。然后它将退回使用背景颜色。另外天空盒组件可以添加到相机上。如果你想创建一个新的天空盒,可以参考官方文档。l “固定的颜色”这个选项会把屏幕上的任何空的部分显示这个固定颜色,其实就是用这个固定的颜色先来设置颜色缓冲区,然后再进行渲染,这样没有被渲染的地方就是原来设置的固定的颜色。 l“只清除深度缓冲区“这个选项将不会清理任何颜色缓冲区里面的内容,只会清理你的深度缓冲区的内容。如果你想绘制一个玩家的枪而不让它在环境内部得到裁剪,你要设置一个深度为0的相机来绘制环境,还要另一个深度为1的相机单独绘制武器。该武器相机的清除标记应设置为仅深度。这将保持环境的图形显示在屏幕上,但会丢弃所有关于每个对象在三维空间中的位置的信息。当枪被绘制出来,不透明的部分将完全覆盖任何已绘制的事物,而不管枪到墙之间如何接近。l “不清除“该模式不清除任何颜色或深度缓存。其结果是,每帧绘制在下一帧之上,造成涂片效果。这不是用于游戏的典型方式,最好是与自定义着色器一起使用。如果我们尝试设置默认的摄像机的清除标记为“不清除“的话会发生什么?恩,效果可能会非常有趣(在进入游戏播放模式以后我稍微移动了下摄像机)。它看起来就像我们的球体本身重复了这么多次,它变成某种有边有角的奇怪东西。除此之外。场景中仍然是有一个红色球的(注意,蓝色层对于摄像机来说仍然是不可见的),游戏场景的图像看起来仍然是有效的。并没有任何形式的图像瑕疵。然而,我们成功地只通过一个物体来创建了有很多重复物体的效果。这种情况的出现是因为在帧与帧切换的过程中颜色缓冲区没有被清空(在之前帧所渲染的颜色缓冲区的内容没有清除,所以转移到下一帧中来了,而且因为一直没有清除,所以一直累加,就出现了上图中的那些奇怪的形状),深度缓冲区的内容同样也没有清除。深度缓冲区的用途是记住已经渲染的物体的深度,因为没有清除,当Unity试图绘制另外一帧的时候深度缓冲区还是保留着这些内容。当球体要在已经被渲染的球体后面进行渲染的时候,那些因为遮挡而不可见的像素会被丢弃掉。在场景有很多物体的情况下,一个物体接着一个物体进行渲染的时候也会发生同样的事情。如果你还是不明白发生了什么,请现在停止阅读并尝试自己动手实现一遍!创建一个新的场景,添加一个对象,设置摄像机的清除标志为“不清除“并不时的移动这个物体或者你的摄像机。(自己动手尝试的核心在于一直移动,或者移动物体,或者移动摄像机,这样不同帧之间绘制出来的内容才会有重叠也有不同,因为没有清除之前帧的颜色缓冲区和深度缓冲区,这样出来的效果才是既有重叠又有遮挡的神奇效果)。使用这些清除选项到底有什么好处?我假设你不希望你的游戏中出现这种效果。所以做这些清除有什么好处呢?现在让我们通过一个有两个摄像机的小例子来说明这个问题。·蓝色摄像机§清除标记: ” 迁移到天空盒缓冲区并清除“§剔除遮罩: 默认层, 蓝色层§深度: 0上面的截图是蓝色摄像机会看到的内容。·红色摄像机§清除标记: ”不清除“§剔除遮罩:红色层§深度: 1上面的截图是红色摄像机会看到的内容。这里面还有一个新的参数:深度。深度限定了摄像机渲染的顺序。深度数值较小的摄像机将会比深度数值较大的摄像机先进行渲染。让我们来看看Unity是如何一步一步的渲染这个场景的(再次强调下,这个过程的解释不是100%准确的,只是为了让我们更好的理解这个过程):(下面的内容都是发生在蓝色摄像机上下文的东西)颜色缓冲区的内容被清理到天空盒里面并清空颜色缓冲区深度缓冲区被清空平面(属于默认层的物体)和蓝色的球体(属于蓝色层的物体)都将被渲染出来(下面的内容都是发生在红色摄像头上下文的东西)没有缓冲区被清空,也就是颜色缓冲区和深度缓冲区的内容都保持不变红色的球体(属于红色层的物体)将被渲染出来所得到的结果就是你会得到一个场景。就像是只用一台单独的摄像机进行渲染的一样:所以为什么要费这么大劲做这么一个事情呢?让我们尝试一件事情来说明下。让我们把红色摄像机的清除标记从“不清除”切换成“只清除深度缓冲区”:哇,你看到了吗?由于深度缓冲区已经被清除,红色的球不知道它在屏幕上渲染的像素会被其他像素遮挡,所以它就像没有被遮挡一样渲染出来了。这意味着清除深度缓冲区会将待渲染的物体渲染在前面。当你想渲染三维的用户交互元素的时候,这个功能可能是超级有用的。在《上古卷轴5:天际》中你可以看到背包中的物品是以三维物体的形式表现出来的。即使背景的物体表现的离摄像机更近也没有影响这些物品的正确渲染。另外一个有趣的选项是将摄像机的效果只对特定层表现出来。让我们尝试对蓝色摄像机使用模糊效果,就像下面的截图所示的这样:现在让我们把红色摄像机的清除标记切换成“不清除”并对蓝色摄像机应用一个不同的效果:灰度化。最后请记住一点,如果你想要移动某个摄像机的话,你可能需要一次移动所有的摄像机(这就是为什么将所有的摄像机作为一个游戏物体的子对象是非常普遍的一个做法,这样移动起来就很简单而不需要一个个移动,既可以避免出错又减少了很多繁琐的操作)。但是有些时候可能只移动一个摄像机是想要做的操作。。。【版权声明】原文作者未做权利声明,视为共享知识产权进入公共领域,自动获得授权。
分类:程序新手圈
请勿发表无意义的内容请勿发表重复内容请勿发表交易类内容禁止发表广告宣传贴请使用文明用语其它
淫秽色情政治倾向人身攻击抄袭剽窃广告刷屏恶意挖坟冒充他人其它
登录后参与讨论。点击深坑之Webview,解决H5调用android相机拍照和录像
最近在开发过程中遇到一个问题,主要是调用第三方的实名认证,需要拍照和录像;
办过支付宝大宝卡和腾讯的大王卡的都知道这玩意,办卡的时候就需要进行实名认证,人脸识别;
本来第三方平台(xxx流量公司)说的是直接用WebView加载这个H5界面就完事了,我心想这么简单,那不是分分钟的事,放着后面做(公司就我一个安卓,所以开发都是我说的算^_^,独立开发有的时候还是挺爽);
结果到项目快要上线的时候,只想说一句mmp,根本调不了相机,这个时候怎么搞,只有自己去实现了,才发现自己已经进了webview的深坑;
到处找资料,发现webview根本不能让h5自己调用,ios是可以的,项目经理就说是我的锅,真特么又一句mmp(关键是这个H5还特么不能改,不能提供给我调用的方法);
进入正题,首先来了解webview,这里我分享两篇大佬的博客
看完这两篇基本你已经可以随意操作webview了,
但是,当你调用相机的时候你才发现这只是入坑的开始
调用相机之后,文件回调不了,其实根本就是没有回调.这个时候你要去检查你的webview的Settings了关键代码,是否给足了权限;
WebSettings settings = webView.getSettings();
settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(true);
settings.setDomStorageEnabled(true);
settings.setDefaultTextEncodingName("UTF-8");
settings.setAllowContentAccess(true);
settings.setAllowFileAccess(true);
settings.setAllowFileAccessFromFileURLs(false);
settings.setAllowUniversalAccessFromFileURLs(false);
settings.setJavaScriptEnabled(true);
settings.setSupportZoom(true);
其中settings.setDomStorageEnabled(true);这个方法当时我没加,血崩了一次;
WebChromeClient的openFileChooser()只调用了一次
首先了解为什么这个方法只调用了一次,看这篇博客就可
看了他基本你就了解怎么回事了
怎么区分是要调用相机是需要拍照还是录视频
这个时候你就要看WebViewClient的 shouldOverrideUrlLoading()方法了,我是通过拦截url来判断url里面是拍照还是录制视频来加一个flag
这样你调用你的相机的时候就可以分别处理了
android 7.0的FileProvider的坑
看洪阳大佬的这篇博客基本就了解了
最后附上我自己的代码吧
package com.sihaiwanlian.cmccnev.feature.verify.
import android.annotation.TargetA
import android.app.A
import android.content.ClipD
import android.content.I
import android.net.U
import android.os.B
import android.os.B
import android.os.E
import android.os.SystemC
import android.provider.MediaS
import android.support.annotation.RequiresA
import android.support.v4.content.FileP
import android.support.v7.app.AppCompatA
import android.text.TextU
import android.util.L
import android.view.KeyE
import android.webkit.ValueC
import android.webkit.WebChromeC
import android.webkit.WebS
import android.webkit.WebV
import android.webkit.WebViewC
import android.widget.B
import android.widget.ImageV
import android.widget.TextV
import com.orhanobut.logger.L
import com.sihaiwanlian.cmccnev.R;
import com.sihaiwanlian.cmccnev.utils.PhotoU
import java.io.F
import butterknife.BindV
import butterknife.ButterK
import butterknife.OnC
public class Certifica extends AppCompatActivity {
private final static String TAG = "villa";
@BindView(R.id.titleBar_iv_back)
ImageView mTitleBarIvB
@BindView(R.id.titleBar_btn_back)
Button mTitleBarBtnB
@BindView(R.id.titleBar_centerTV)
TextView mTitleBarCenterTV;
private WebView webV
private ValueCallback&Uri& mUploadM
private ValueCallback&Uri[]& mUploadCallbackAboveL;
private final static int PHOTO_REQUEST = 100;
private final static int VIDEO_REQUEST = 120;
private final static String url = "your_url";
private boolean videoFlag = false;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_certifica);
ButterKnife.bind(this);
initToolBar();
initWebView();
private void initToolBar() {
mTitleBarCenterTV.setText("实名认证");
private void initWebView() {
webView = (WebView) this.findViewById(R.id.certifi_webview);
initWebViewSetting();
@RequiresApi(api = Build.VERSION_CODES.JELLY_BEAN)
private void initWebViewSetting() {
WebSettings settings = webView.getSettings();
settings.setUseWideViewPort(true);
settings.setLoadWithOverviewMode(true);
settings.setDomStorageEnabled(true);
settings.setDefaultTextEncodingName("UTF-8");
settings.setAllowContentAccess(true);
settings.setAllowFileAccess(true);
settings.setAllowFileAccessFromFileURLs(false);
settings.setAllowUniversalAccessFromFileURLs(false);
settings.setJavaScriptEnabled(true);
settings.setSupportZoom(true);
webView.setWebViewClient(new MyWebViewClient());
webView.setWebChromeClient(new MyChromeWebClient());
webView.loadUrl(url);
@OnClick(R.id.titleBar_btn_back)
public void onViewClicked() {
if (webView.canGoBack()) {
webView.goBack();
private class MyWebViewClient extends WebViewClient {
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Logger.e(url);
if (!TextUtils.isEmpty(url)) {
videoFlag = url.contains("vedio");
if (url.trim().startsWith("tel")) {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
String port = url.substring(url.lastIndexOf(":") + 1, url.lastIndexOf("/"));
if (port.equals("808")) {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
view.loadUrl(url);
return true;
private File fileUri = new File(Environment.getExternalStorageDirectory().getPath() + "/" + SystemClock.currentThreadTimeMillis() + ".jpg");
private Uri imageU
public class MyChromeWebClient extends WebChromeClient {
public void openFileChooser(ValueCallback&Uri& uploadMsg) {
Log.d(TAG, "openFileChoose(ValueCallback&Uri& uploadMsg)");
mUploadMessage = uploadM
if (videoFlag) {
recordVideo();
takePhoto();
public void openFileChooser(ValueCallback uploadMsg, String acceptType) {
Log.d(TAG, "openFileChoose( ValueCallback uploadMsg, String acceptType )");
mUploadMessage = uploadM
if (videoFlag) {
recordVideo();
takePhoto();
public void openFileChooser(ValueCallback&Uri& uploadMsg, String acceptType, String capture) {
Log.d(TAG, "openFileChoose(ValueCallback&Uri& uploadMsg, String acceptType, String capture)");
mUploadMessage = uploadM
if (videoFlag) {
recordVideo();
takePhoto();
public boolean onShowFileChooser(WebView webView, ValueCallback&Uri[]& filePathCallback, FileChooserParams fileChooserParams) {
Log.d(TAG, "onShowFileChooser(ValueCallback&Uri& uploadMsg, String acceptType, String capture)");
mUploadCallbackAboveL = filePathC
if (videoFlag) {
recordVideo();
takePhoto();
return true;
private void takePhoto() {
imageUri = Uri.fromFile(fileUri);
if (Build.VERSION.SDK_INT &= Build.VERSION_CODES.N) {
imageUri = FileProvider.getUriForFile(Certifica.this, getPackageName() + ".fileprovider", fileUri);
PhotoUtils.takePicture(Certifica.this, imageUri, PHOTO_REQUEST);
private void recordVideo() {
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1);
intent.putExtra(MediaStore.EXTRA_DURATION_LIMIT, 10);
startActivityForResult(intent, VIDEO_REQUEST);
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK) && webView.canGoBack()) {
webView.goBack();
return true;
return super.onKeyDown(keyCode, event);
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == PHOTO_REQUEST) {
if (null == mUploadMessage && null == mUploadCallbackAboveL) return;
Uri result = data == null || resultCode != RESULT_OK ? null : data.getData();
if (mUploadCallbackAboveL != null) {
onActivityResultAboveL(requestCode, resultCode, data);
} else if (mUploadMessage != null) {
mUploadMessage.onReceiveValue(result);
mUploadMessage = null;
} else if (requestCode == VIDEO_REQUEST) {
if (null == mUploadMessage && null == mUploadCallbackAboveL) return;
Uri result = data == null || resultCode != RESULT_OK ? null : data.getData();
if (mUploadCallbackAboveL != null) {
if (resultCode == RESULT_OK) {
mUploadCallbackAboveL.onReceiveValue(new Uri[]{result});
mUploadCallbackAboveL = null;
mUploadCallbackAboveL.onReceiveValue(new Uri[]{});
mUploadCallbackAboveL = null;
} else if (mUploadMessage != null) {
if (resultCode == RESULT_OK) {
mUploadMessage.onReceiveValue(result);
mUploadMessage = null;
mUploadMessage.onReceiveValue(Uri.EMPTY);
mUploadMessage = null;
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private void onActivityResultAboveL(int requestCode, int resultCode, Intent data) {
if (requestCode != PHOTO_REQUEST || mUploadCallbackAboveL == null) {
Uri[] results = null;
if (resultCode == Activity.RESULT_OK) {
if (data == null) {
results = new Uri[]{imageUri};
String dataString = data.getDataString();
ClipData clipData = data.getClipData();
if (clipData != null) {
results = new Uri[clipData.getItemCount()];
for (int i = 0; i & clipData.getItemCount(); i++) {
ClipData.Item item = clipData.getItemAt(i);
results[i] = item.getUri();
if (dataString != null)
results = new Uri[]{Uri.parse(dataString)};
mUploadCallbackAboveL.onReceiveValue(results);
mUploadCallbackAboveL = null;
protected void onDestroy() {
super.onDestroy();
if (webView != null) {
webView.setWebViewClient(null);
webView.setWebChromeClient(null);
webView.loadDataWithBaseURL(null, "", "text/html", "utf-8", null);
webView.clearHistory();
webView.destroy();
webView = null;
这里面有个photoUtils,已经封装好了各种调用,简单好用
public class PhotoUtils {
private static final String TAG = "PhotoUtils";
* activity
当前activity
* imageUri
拍照后照片存储路径
* requestCode 调用系统相机请求码
public static void takePicture(Activity activity, Uri imageUri, int requestCode) {
Intent intentCamera = new Intent();
if (Build.VERSION.SDK_INT &= Build.VERSION_CODES.N) {
intentCamera.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intentCamera.setAction(MediaStore.ACTION_IMAGE_CAPTURE);
intentCamera.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
if (activity!=null){
activity.startActivityForResult(intentCamera, requestCode);
* activity
当前activity
* requestCode 打开相册的请求码
public static void openPic(Activity activity, int requestCode) {
Intent photoPickerIntent = new Intent(Intent.ACTION_GET_CONTENT);
photoPickerIntent.setType("image/*");
activity.startActivityForResult(photoPickerIntent, requestCode);
* activity
当前activity
剪裁原图的Uri
剪裁后的图片的Uri
X方向的比例
Y方向的比例
剪裁图片的宽度
剪裁图片高度
* requestCode 剪裁图片的请求码
public static void cropImageUri(Activity activity, Uri orgUri, Uri desUri, int aspectX, int aspectY, int width, int height, int requestCode) {
Intent intent = new Intent("com.android.camera.action.CROP");
if (Build.VERSION.SDK_INT &= Build.VERSION_CODES.N) {
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.setDataAndType(orgUri, "image/*");
intent.putExtra("crop", "true");
intent.putExtra("aspectX", aspectX);
intent.putExtra("aspectY", aspectY);
intent.putExtra("outputX", width);
intent.putExtra("outputY", height);
intent.putExtra("scale", true);
intent.putExtra(MediaStore.EXTRA_OUTPUT, desUri);
intent.putExtra("return-data", false);
intent.putExtra("outputFormat", Bitmap.CompressFormat.JPEG.toString());
intent.putExtra("noFaceDetection", true);
activity.startActivityForResult(intent, requestCode);
* 读取uri所在的图片
图片对应的Uri
* mContext 上下文对象
* 获取图像的Bitmap
public static Bitmap getBitmapFromUri(Uri uri, Context mContext) {
Bitmap bitmapFormUri = getBitmapFormUri(mContext, uri);
return bitmapFormU
} catch (Exception e) {
e.printStackTrace();
return null;
* 通过uri获取图片并进行压缩
public static Bitmap getBitmapFormUri(Context ac, Uri uri) throws FileNotFoundException, IOException {
InputStream input = ac.getContentResolver().openInputStream(uri);
BitmapFactory.Options onlyBoundsOptions = new BitmapFactory.Options();
onlyBoundsOptions.inJustDecodeBounds = true;
onlyBoundsOptions.inDither = true;
onlyBoundsOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;
BitmapFactory.decodeStream(input, null, onlyBoundsOptions);
input.close();
int originalWidth = onlyBoundsOptions.outW
int originalHeight = onlyBoundsOptions.outH
if ((originalWidth == -1) || (originalHeight == -1)){
return null;
float hh = 800f;
float ww = 480f;
int be = 1;
if (originalWidth & originalHeight && originalWidth & ww) {
be = (int) (originalWidth / ww);
} else if (originalWidth & originalHeight && originalHeight & hh) {
be = (int) (originalHeight / hh);
if (be &= 0){
BitmapFactory.Options bitmapOptions = new BitmapFactory.Options();
bitmapOptions.inSampleSize =
bitmapOptions.inDither = true;
bitmapOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;
input = ac.getContentResolver().openInputStream(uri);
Bitmap bitmap = BitmapFactory.decodeStream(input, null, bitmapOptions);
input.close();
return compressImage(bitmap);
* 质量压缩方法
public static Bitmap compressImage(Bitmap image) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
image.compress(Bitmap.CompressFormat.JPEG, 100, baos);
int options = 100;
while (baos.toByteArray().length / 1024 & 100) {
baos.reset();
image.compress(Bitmap.CompressFormat.JPEG, options, baos);
options -= 10;
ByteArrayInputStream isBm = new ByteArrayInputStream(baos.toByteArray());
Bitmap bitmap = BitmapFactory.decodeStream(isBm, null, null);
* context 上下文对象
当前相册照片的Uri
* 解析后的Uri对应的String
@SuppressLint("NewApi")
public static String getPath(final Context context, final Uri uri) {
final boolean isKitKat = Build.VERSION.SDK_INT &= Build.VERSION_CODES.KITKAT;
String pathHead = "file:///";
if (isKitKat && DocumentsContract.isDocumentUri(context, uri)) {
if (isExternalStorageDocument(uri)) {
final String docId = DocumentsContract.getDocumentId(uri);
final String[] split = docId.split(":");
final String type = split[0];
if ("primary".equalsIgnoreCase(type)) {
return pathHead + Environment.getExternalStorageDirectory() + "/" + split[1];
else if (isDownloadsDocument(uri)) {
final String id = DocumentsContract.getDocumentId(uri);
final Uri contentUri = ContentUris.withAppendedId(Uri.parse("content://downloads/public_downloads"), Long.valueOf(id));
return pathHead + getDataColumn(context, contentUri, null, null);
else if (isMediaDocument(uri)) {
final String docId = DocumentsContract.getDocumentId(uri);
final String[] split = docId.split(":");
final String type = split[0];
Uri contentUri = null;
if ("image".equals(type)) {
contentUri = MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
} else if ("video".equals(type)) {
contentUri = MediaStore.Video.Media.EXTERNAL_CONTENT_URI;
} else if ("audio".equals(type)) {
contentUri = MediaStore.Audio.Media.EXTERNAL_CONTENT_URI;
final String selection = "_id=?";
final String[] selectionArgs = new String[]{split[1]};
return pathHead + getDataColumn(context, contentUri, selection, selectionArgs);
else if ("content".equalsIgnoreCase(uri.getScheme())) {
return pathHead + getDataColumn(context, uri, null, null);
else if ("file".equalsIgnoreCase(uri.getScheme())) {
return pathHead + uri.getPath();
return null;
* Get the value of the data column for this Uri. This is useful for
* MediaStore Uris, and other file-based ContentProviders.
The context.
The Uri to query.
* selection
(Optional) Filter used in the query.
* selectionArgs (Optional) Selection arguments used in the query.
* The value of the _data column, which is typically a file path.
private static String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs) {
Cursor cursor = null;
final String column = "_data";
final String[] projection = {column};
cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null);
if (cursor != null && cursor.moveToFirst()) {
final int column_index = cursor.getColumnIndexOrThrow(column);
return cursor.getString(column_index);
} finally {
if (cursor != null){
cursor.close();
return null;
* uri The Uri to check.
* Whether the Uri authority is ExternalStorageProvider.
private static boolean isExternalStorageDocument(Uri uri) {
return "com.android.externalstorage.documents".equals(uri.getAuthority());
* uri The Uri to check.
* Whether the Uri authority is DownloadsProvider.
private static boolean isDownloadsDocument(Uri uri) {
return "com.android.providers.downloads.documents".equals(uri.getAuthority());
* uri The Uri to check.
* Whether the Uri authority is MediaProvider.
private static boolean isMediaDocument(Uri uri) {
return "com.android.providers.media.documents".equals(uri.getAuthority());
没有更多推荐了,}

我要回帖

更多关于 beαuty相机 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信