ToyaWebViewの判別方法
User-Agentに「ToyaWebView」の文字列が追加されます。
Android端末はWindowsPCに比べ安価で汎用的ですが、倉庫業務でのWebシステムではどうしても印刷周り(ラベルプリンタを含む)が課題
ダウンロードファイルを対応アプリに投げる。(例:PDFは各プリンタユーティリティに投げ直接印刷など※対応していないプリンタはWindowsPCにファイルを送るなど)
JavaScriptでソフトウェアキーボードの表示非表示、ビープ音、バイブレーションをコントロール可能とする。
ファンクションキーを使いたい。
パスワードやフォームデータの保存は行わない、画面の向きは変えさせないなど汎用性を極力省く
別端末(PCなど)からのブラウザ画面画像、端末位置(GPS)、ログ照会など簡易保守機能
*警告*JavaScriptからのセキュリティ脆弱性があります。信用できるサイトだけでご利用ください。
*警告*ダウンロードファイルに対する脆弱性があります。信用できるサイトだけでご利用ください。
以下WebViewでは解決困難、、、サーバー側で対応が必要(Chromeブラウザのみ対応している模様)
POSTメソッドでのダウンロードはできない。
ダウンロード時は二重送信が行われる。
User-Agentに「ToyaWebView」の文字列が追加されます。
Fromに「ToyaWebView-Download」の文字列が追加されます。
表示
非表示
http://toyareader.web.fc2.com/script.html
<label for='invoice'>送り状</label>
<input type='text' name='invoice' id='invoice'/>
<label for='shipping'>伝票</label>
<input type='text' name='shipping' id='shipping'/>
<script type="text/javascript">
$(function() {
$("#invoice").focus();
if(navigator.userAgent.toLowerCase().indexOf('toyawebview',0) >= 0){
window.toya.showKeyBoard();
window.toya.startTone(25, 35);
window.toya.vibrate(500);
}
$("#invoice").keypress(function (e) {
if ((e.which && e.which == 13)||(e.keyCode && e.keyCode == 13)){
if($("#invoice").val()!=""){
$("#shipping").focus();
if(navigator.userAgent.toLowerCase().indexOf('toyawebview',0) >= 0){
window.toya.showKeyBoard();
window.toya.startTone(25, 35);
window.toya.vibrate(500);
}
}
return false;
}
});
});
</script>
起動Intent用AndroidManifest.xml例
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:mimeType="text/csv"/>
<data android:mimeType="application/pdf"/>
「メニュー」→「管理」を起動。「Password」「Retype」(パスワードの確認)「Port」を入力して 「Start」ボタンを押下する。Activeを確認したらPCブラウザからLANのIPv4(http://IPAddress:Port/)にアクセスします。