在Android的使用JavaScript启动相机应用 [英] Launching Camera App Using Javascript in android
本文介绍了在Android的使用JavaScript启动相机应用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否有可能通过Android的JSInterface启动相机应用?目前,我可以通过JavaScript从Android $访问测试()C $ C.I希望通过使用JSInterface推出通过javascript相机应用。
jQuery的:
$(函数(){
FastClick.attach(document.body的);
$('。BTN-初级板')。点击(函数(){
警报(android.test()); // WebViewFragment.Java-> JsInterface-> getPhoneNumber
});
});
块引用>的Android code:
公共类JsInterface {
公共字符串测试()
{
//这里调用任何公共活动方法....
返回WebViewFragment.Java-> JsInterface-> getPhoneNumber
}
}
解决方案也许试试这个:
公共类JsInterface {
公共无效launchCamera()
{
意向意图=新意图(android.media.action.IMAGE_CAPTURE);
startActivityForResult(意向,0);
}
}和别忘了权限:
<使用许可权的android:NAME =android.permission.CAMERA>< /使用许可权>
,然后只用
android.launchCamera()
从JS。Is it possible to launch the camera app via Android JSInterface?Currently I can access the test() via javascript from the android code.I want to launch the camera app via javascript by using JSInterface.
jQuery:
$(function() { FastClick.attach(document.body); $('.btn-primary-panel').click(function(){ alert(android.test());// WebViewFragment.Java->JsInterface->getPhoneNumber }); });
Android Code:
public class JsInterface{ public String test() { // Here call any of the public activity methods.... return "WebViewFragment.Java->JsInterface->getPhoneNumber"; } }
解决方案Maybe try this:
public class JsInterface{ public void launchCamera() { Intent intent = new Intent("android.media.action.IMAGE_CAPTURE"); startActivityForResult(intent, 0); } }
And don't forget the permissions:
<uses-permission android:name="android.permission.CAMERA"></uses-permission>
And then just use
android.launchCamera()
from JS.这篇关于在Android的使用JavaScript启动相机应用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文