sencha-touch下借助phoneGap实现拍照,二维码的功能

1.配置

在android项目中拷入相应的文件,layout+raw+values+xml

AndroidMainfest.xml中注册

 <activity android:name="com.Plugin.scan.CaptureActivity" android:configChanges="orientation|keyboardHidden|screenSize" android:screenOrientation="landscape" android:theme="@android:style/Theme.NoTitleBar.Fullscreen" android:windowSoftInputMode="stateAlwaysHidden"></activity>  

native文件夹下src下的com中拷入Plugin文件夹,相应的error的地方,改成import自己的项目即ok

core.jar文件拷到libs下,并add 到buildPath里

拍照:

navigator.camera.getPicture(Success, Fail, {
quality : 50,
sourceType : Camera.PictureSourceType.CAMERA,
destinationType : Camera.DestinationType.FILE_URI
});
function Success(imageURI) {
onSuccess(imageURI);
}
function Fail(message) {
onFail(message);
}

二维码:

var me = this;
var nativePage = me._getScanNativePage();
WL.NativePage.show(nativePage, function(data) {
if (null == data.str || data.str == "") {
onFail("no_message");
} else {
console.log("data == " + data.str);
onSuccess(data.str);
}
}, null);


_getScanNativePage : function() {
console.log("_getScanNativePage");
var enviroment = WL.Client.getEnvironment();
console.log("getEnvironment");
var me = this;
if (enviroment == WL.Environment.ANDROID) {
nativePage = me.SCAN_ACTIVITY;
console.log("this is android");
} else if (enviroment == WL.Environment.IPHONE
|| enviroment == WL.Environment.IPAD) {
// set the iPhone native page path here.
nativePage = me.SCAN_VIEWCONTROLLER;
}
return nativePage;
},

你可能感兴趣的:(sencha-touch下借助phoneGap实现拍照,二维码的功能)