我正在使用junaio模板(增强现实)for android,我添加了一个名为'Scan'的按钮,它将扫描qr代码。我需要知道我必须在android上实现什么方法/函数/类或API才能使该操作起作用。这有什么用于Android?。
提前感谢!
PS:我听说过Zxing,但如果我没错,应用程序需要安装在手机上,我不想,因为我正在开发我自己的应用程序,我打算这样做会做整个工作答案 0 :(得分:2)
我不知道,但你可以研究ZXing源代码他们是如何做到的http://code.google.com/p/zxing/source/checkout
答案 1 :(得分:1)
为了在junaio中实现扫描功能,您必须设置跟踪配置“arel.Tracking.BARCODE_QR”(http://dev.junaio.com/arel/documentationArelJS/symbols/arel.Tracking.html)
每次扫描QR码时,您都会通过onTrackingEvent回调获得回调。 在该回调中,您可以决定要执行的操作。
答案 2 :(得分:0)
好的,情况就是这样,我已经对代码做了一些建议的更改,以便它可以扫描QR码。我在文件index.php上进行的更改是在文件夹arel中进行的。
<script type="text/javascript">
arel.sceneReady(function()
{
//start with arel here
arel.Scene.setTrackingConfiguration(arel.Tracking.BARCODE_QR);
//set a listener to tracking to get information about when the image is tracked
arel.Events.setListener(arel.Scene, function(type, param){trackingHandler(type, param);});
//if the user holds the device over the pattern already, when the scene starts
arel.Scene.getTrackingValues(function(trackingValues){receiveTrackingStatus(trackingValues);});
});
function trackingHandler(type, param)
{
//check if there us tracking information avaialbe
if(param[0] !== undefined)
{
//if the pattern is found, hide the information to hold your phone over the pattern
if(type && type == arel.Events.Scene.ONTRACKING && para[0].getState() == arel.Tracking.STATE_TRACKING)
{
$('#info').fadeOut("fast");
}
//if the pattern is lost tracking, show the information to hold your phone over the pattern
else if(type && type == arel.Events.Scene.ONTRACKING && param[0].getState() == arel.Tracking.STATE_NOTTRACKING)
{
$('#info').fadeIn("fast");
}
}
};
function receiveTrackingStatus(trackingValues)
{
if(trackingValues[0] === undefined)
$('#info').fadeIn("fast");
};
</script>
这里的问题是它没有扫描任何代码,我把手机扫描一下代码而没有任何反应......任何人都知道我在这里做错了什么?...我会吝啬任何帮助。
感谢。
伊格纳西奥。