mickeyckm / ti-qrcode

QR code generator for Titanium Appcelerator
18 stars 6 forks source link

Doesn't work on certain phones #2

Open krstns opened 12 years ago

krstns commented 12 years ago

Hello,

I can only get this to work with Android version 4.x and above [haven't tried 3.x]. None of the emulators nor handsets with Android 2.2 nor 2.3 work with this.

I'm trying to encode something as simple as 'abecadlo' using this code:

    var QRCodeView = require('qr/qrcode');
    var qrCodeView = new QRCodeView(code, 2);
    qrCodeView.size = {
        width : Ti.Platform.displayCaps.platformWidth * 0.7,
        height : Ti.Platform.displayCaps.platformWidth * 0.7,
    }
    win.add(qrCodeView)

Also, this is what I get on emulator 4.x [although it shows the code]

D/TiWebViewBinding(  474): (KrollRuntimeThread) [961,4204] getJSValue:javascript:_TiReturn.setValue((function(){try{return doqr(unescape('abecadlo'), 2);+"";}catch(ti_eval_err){return '';}})());
W/webview (  474): java.lang.Throwable: Warning: A WebView method was called on thread 'KrollRuntimeThread'. All WebView methods must be called on the UI thread. Future versions of WebView may not support use on other threads.
W/webview (  474):  at android.webkit.WebView.checkThread(WebView.java:9468)
W/webview (  474):  at android.webkit.WebView.loadUrl(WebView.java:2087)
W/webview (  474):  at ti.modules.titanium.ui.widget.webview.TiWebViewBinding.getJSValue(TiWebViewBinding.java:127)
W/webview (  474):  at ti.modules.titanium.ui.widget.webview.TiUIWebView.getJSValue(TiUIWebView.java:460)
W/webview (  474):  at ti.modules.titanium.ui.WebViewProxy.evalJS(WebViewProxy.java:91)
W/webview (  474):  at org.appcelerator.kroll.runtime.v8.V8Object.nativeFireEvent(Native Method)
W/webview (  474):  at org.appcelerator.kroll.runtime.v8.V8Object.fireEvent(V8Object.java:60)
W/webview (  474):  at org.appcelerator.kroll.KrollProxy.doFireEvent(KrollProxy.java:629)
W/webview (  474):  at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:822)
W/webview (  474):  at android.os.Handler.dispatchMessage(Handler.java:95)
W/webview (  474):  at android.os.Looper.loop(Looper.java:137)
W/webview (  474):  at org.appcelerator.kroll.KrollRuntime$KrollRuntimeThread.run(KrollRuntime.java:104)
krstns commented 12 years ago

After few hours of pulling my hair I got to the center of it:

In setupqr() function:

wd = window.innerWidth;
ht = window.innerHeight;

On Android < 4.0 these two variables will be set to 0. This way the canvas has no size, thus it is not shown on screen after the code is generated.

I'm not sure how to create a generic solution for all of the Android versions, but for me, where I need to specify concrete values, it makes this 'plugin' work.

AppWerft commented 9 years ago

I have the same problem. With this code: https://github.com/lrsjng/jquery-qrcode/blob/master/src/lib/qrcode.js you can a plain graphic too. Unfortunately it generates GIF. Perhaps there is a converter. If you have net you can use one of thousand web services, which generates PNG