I have here an Android device with a build in hardware barcode scanner module with a hardware scan button. I never developed an android app. but i checked the SDK of the device. The sample app uses a BroadcastReceiver to get the result of successful barcode scans.
private BroadcastReceiver mScanReceiver = new BroadcastReceiver() {
....
}
....
protected void onResume() {
super.onResume();
IntentFilter filter = new IntentFilter();
filter.addAction(SCAN_ACTION);
registerReceiver(mScanReceiver, filter);
}
Because i'm not familiar with java I don't want to develop an app to use this device. I want to use the scanner in chrome browser instead, to work with HTML5, pouchDB & javascript.
So my questions are:
Can I listen for such android Broadcasts in the chrome browser? (how?)
If this is not possible, i think about building a simple app which opens "Chrome Custom Tabs". Is it possible to pass messages from the app to its Chrome custom tabs?
Or is there another way to solve this?
Related
I am developing a Xamarin Android and iOS app, the app is using Webview to display the webpage content, I followed the article's tutorial:
Customizing a WebView
And there is a button in my Webview webpage, I want this app can automatically click the button when app finish load the Webview.
In Android project, I found how to do this , tested in Android simulator and it worked:
JavascriptWebViewClient.cs
public override void OnPageFinished(WebView view, string url)
{
base.OnPageFinished(view, url);
view.EvaluateJavascript(_javascript, null);
view.LoadUrl("javascript:document.getElementById('btn_sign').click()");
}
but I don't know how to achieve this function in iOS project?
My iOS project has HybridWebViewRenderer.cs, I think maybe I need to do something similar,
but I can't solve this after did a lot of research.
Can anyone help me solve this?
Thanks!!!
How can I send an android intent from a vue-web-app?
For example to start an external app to scan a barcode and return the barcode number.
I have a vue web app which runs in a browser environment and I want to start a native android app to scan a barcode. How can I send an "android intent" from this vue-web-app to achieve this? Do I need a specific plugin for example?
The app you're trying to start needs to have a custom URL scheme defined in the intent filter. In that case you'll have an URI looking like this: demoapp://scan?type=128
When your Vue app redirects to an URI like this on an Android phone (with the app installed) it will pick up the intent and launch the app with corresponding activity started.
I'm trying to develop an application based on Spring MVC for mobile device. Spring Mobile do provide such features to view our application in mobile browser. But how can I run/deploy the application in emulator since it's non-android based application? Also if can anybody tell me, how can I test it in real device, It will be highly appreciated.
I'm using DHTMLX touch framework for javascript as well as HTML5.
Just a snippet of code below for spring mobile:
#RequestMapping("/detect-device")
public #ResponseBody String detectDevice(Device device)
{ String deviceType = "unknown";
if (device.isNormal())
{ deviceType = "normal"; }
else if (device.isMobile())
{ deviceType = "mobile"; }
else if (device.isTablet())
{ deviceType = "tablet"; }
Since you're not actually developing a mobile app (which would be installed on the mobile device itself) but a web page that detects and supports mobile devices, you don't need an Android emulator.
What you do need is a browser that allows emulating a mobile client - Chrome has a neat Device Mode & Mobile Emulation which is a part of the standard Dev Tools. The Chrome Developer page has a nice overview and a tutorial; all you need to do to get started is to click the tiny smartphone icon in the developer tools panel.
Haven't investigated Firefox, but I'm assuming there is at least one plugin that offers similar functionality.
I am building one android application using cordova/phonegap and Javascript. I am using scandit barcode scanner for scanning functionality. Scandit barcode scanner occupies entire screen while scaaning. But I need scanning only in perticular area/div in my application. How can I solve that issue? Is there any other scanner which can solve this issue?
If you are just calling BarcodeScanner via an intent you have no control. However if you are embedding the Java code from the BarcodeScanner app in your app you have all the java code and xml resources available and can edit them how you like. It will all be Java and native Android resource stuff though.. not html.
If you are embedding the layout is
http://code.google.com/p/zxing/source/browse/trunk/android/res/layout/capture.xml
and the activity that does the scanning you want to edit is
http://code.google.com/p/zxing/source/browse/trunk/android/src/com/google/zxing/client/android/CaptureActivity.java
If you add a button in the layout and call finish in the OnClickListener you set up in the activity it would be a back as you desire..
I have a webpage that is being viewed from a webview in a native app, this webpage has a element. The file input works fine in the web browser but does not work in the app (different problems on both iPhone and Android).
The app has already been published and I would really not like to update the native portion of the app.
The ideal solution would be to add java-script to the webpage that can detect that it is running inside the app and then launch a browser (outside of the app) with the URL.
Is this possible somehow?
It's possible if your app overrides default user agent used by webview. By default the user agent for webview is same as that of default browser. So you don't have any way to differentiate those. If your app overrides useragent, then you can sniff useragent using javascript & take action based on that. Ideal solution will be to try to fix the problem with your html though.
My understanding is that it's impossible to launch the browser which is outside of the app without changing the app.
You may add a code like below in iOS.
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
NSString *address = request.URL.absoluteString;
if( address is needed to be launched on the webbrowser ) {
[[UIApplication sharedApplication] openURL:request.URL];
return NO;
}
return YES;
}
It's recommanded to define a protocol between the webpage and the app. Cheers.
Launching a browser should be no problem, as posted here:
Can I launch an intent using only javascript in an Android browser?
However, detecting the app is tough. If you are already using a javascript bridge in the app, then you can make a call to the native app javascript bridge and if it succeeds, then you know you are in "your app" and can respond with the intent call above.
Failing that, user agent detection, as mentioned elsewhere, may be your best option.
In other words, you need an identifiable and unique action within the webview in order to have confidence that you are actually in it. If you did a plain vanilla implementation, then you will be forced into either having user interaction ("If you are using our app, click here" - horrible!) or updating the native app.