I am using Trigger.io to develop an application.
After using file.getImage and selecting an image from either the gallery or camera (on Android) I get this error message (Using trigger.io toolkit to run the app).
W Forge : Unhandled intent result, should have been handled by Forge.
The app promptly crashes and restarts.
relevant code:
forge.file.getImage({}, function(file) {
forge.request.ajax({
type: 'POST',
url: "http://example.com/upload/photo",
files: [file],
success: function(e) {
console.log('success');
console.log(JSON.stringify(e));
},
error: function(e) {
console.log('failure');
console.log(JSON.stringify(e));
}
});
What does this error mean?
I'm seeing this issue on older devices too. Apparently it's a common issue on both Phonegap and Native android apps also. More can be seen on this thread:
PhoneGap camera restarts the application
The following plugin was developed for Phonegap which resolves the issue. I would be great if something like this could be developed for Trigger.io
http://code.google.com/p/foreground-camera-plugin/
This problem is caused by the camera taking up memory on older Android devices causing it to unceremoniously shut down some apps to free up more memory.
We're working on providing more elegant handling of this situation or at least better debug output to tell you what's going on. The problem in this case was occurring on an Android 2.3 device, and could be worked around by shutting down some open apps / processes.
Update: we released a new foreground camera module to address this issue in our v1.4.41. platform version:
http://current-docs.trigger.io/modules/camera.html#modules-camera
Related
Currently I'm trying to build a web app using the Samsung Tab A. I thought this device would support Service Workers, cause following Can I Use says Chrome for Android 55 is required to run SW.
The tablet is running Android 6.0.1 (no more updates available) and Chrome 55.0.2, but unfortunately when the code shown below runs, the 'no sw' alert pops up.. The SW works fine in Chrome on desktop (mac OS).
if('serviceWorker' in navigator) {
navigator.serviceWorker.register('/sw.js').then((registration) => {
alert('sw');
console.log('ServiceWorker successful, scope: ', registration.scope);
}).catch((err) => {
alert('no sw');
console.log('ServiceWorker failed: ', err);
});
}
Am I doing something wrong, or is it not possible to run SW on this kind of tablet? What else is needed if Chrome 55 isn't enough? I think there is some lack of information about this topic since I can't find the answer on this .. :(
Thanks in advance!
EDIT: I'd already enable multiple flags via chrome://flags without any success..
I was using ngrok to serve my webapp locally to my tablet. Did forget to use https..
Go to chrome://flags and add the url like http://localhost:3000/ to the unsafe input
if you don't know just follow the picture bellow.
https://i.ibb.co/Tvwv6VN/Screenshot-20220727-223110.jpg
after this re launch your chrome or any browser.
I know there is a lot of questions and answers about this in Stackoverflow, I read a lot of them, but none of them work.
I clarified in the title Android WebView because it is the most important target, but I would like this works in other devices too. I tested the following code on a app built with Intel XDK installed on a SM-G355M with Android 4.4.2 and on Safari installed on an iPhone 5C with iOS 9.3.4;
All I get in both cases is the same value, true (sometimes I get false even I have an internet connection).
I tried:
navigator.onLine, it gives always the same value.
document.addEventListener("online", ... doesn't trigger
ajax doesn't work, anyway doesn't affect to the server?
Code: https://nanilab.com/stackoverflow/webview-internet-connection.php(This link is now broken)
Option 1:
function option1(){
var isOffline = 'onLine' in navigator && !navigator.onLine,
text = isOffline == true ? ' without connection ' : ' connected ';
$('.option-one span').text(text);
$('.option-one i').text('checked').hide().fadeIn(200);
setTimeout(function(){
option1();
}, 1000);
}
Option 2:
window.addEventListener("offline", function(){ $('.option-two span').text(' without connection'); }, false);
window.addEventListener("online", function(){ $('.option-two span').text(' connected'); }, false);
Option 3:
function option3(){
$.ajax({
url: '/stackoverflow/blank.php',
success: function(data){
print(' connected ');
},
error: function(jqXHR, textStatus, error) {
print(' without connection ');
}
});
function print(text){
$('.option-three span').text(text);
$('.option-three i').text('checked').hide().fadeIn(200);
setTimeout(function(){
option3();
}, 2000);
}
}
app built with Intel XDK installed on a SM-G355M with Android 4.4.2
https://youtu.be/wHJHG5dP_eM
What I am doing wrong?
Apache Cordova (was called PhoneGap) is an open-source mobile development framework. It allows you to use standard web technologies - HTML5, CSS3, and JavaScript for cross-platform development. Applications execute within wrappers targeted to each platform, and rely on standards-compliant API bindings to access each device's capabilities such as sensors, data, network status, etc.
document reference cordova
In your problem (Option 1):
navigator.onLine
...is not working because (on android) it is broken {the "raw" version, Cordova enabled webview is different}(as you have found out), you have to built your WebView App with the Cordova Framework. Cordova was developed EXACTLY to solve this problem. The GAP in PhoneGap is the gap between the "virtual machine", "sandbox" and access to the hardware, AND it's cross-platform.
Android Permissions:
app/AndroidManifest.xml
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
Cordova Permissions:
app/res/xml/config.xml
<feature name="NetworkStatus">
<param name="android-package" value="org.apache.cordova.networkinformation.NetworkManager" />
</feature>
Quick Guide Cordova installation
goto web page for installation instructions
https://cordova.apache.org/docs/en/latest/guide/cli/
goto web page and download nodejs for your system
https://nodejs.org/en/download/
example file
node-v4.5.0-x86.msi
run (install it)
success.
on Windows:
C:\>npm install -g cordova
And away you go!
I have built your code into cordova, I'm getting there (hopefully, hard problem), here's some image's of what I have so far [not in WebView exactly yet, {see the navigator.userAgent output in the second image}] (notice the event listener is working ;O), but not good enough:o( ).
In Chrome and Safari, if the browser is not able to connect to a local area network (LAN) or a router, it is offline; all other conditions return true. So while you can assume that the browser is offline when it returns a false value, you cannot assume that a true value necessarily means that the browser can access the internet. You could be getting false positives, such as in cases where the computer is running a virtualization software that has virtual ethernet adapters that are always "connected." Therefore, if you really want to determine the online status of the browser, you should develop additional means for checking. To learn more, see the HTML5 Rocks article, http://www.html5rocks.com/en/mobile/workingoffthegrid/
Its working in my current 3.7.1 version, but when I upgraded to 4.x, the back button is not working, to reproduce (working with non http source) :
cordova create test
cd test, change the index.js :
onDeviceReady: function() {
app.receivedEvent('deviceready');
document.addEventListener("backbutton", function() {
alert('back');
});
},
cordova platform add android
cordova build android
but if the config.xml was changed for example :
and rebuild again,the back button is not alerting, what I try to resolve :
#index.html add
Try inspect device using chrome and there's no error, and device ready event is fired
Anybody can help ?
Thanks
#polymerAngular,
I've got some demo Apps, that are exclusively for testing Phonegap Events. You can test all in pairs or singularly. The Backbutton works with 3.5.0.
All Events: https://github.com/jessemonroy650/Phonegap-Events-test
Backbutton: https://github.com/jessemonroy650/Phonegap-PhysicalButton-test
2nd response for #polymerAngular
Apparently Phonegap Build does NOT support 4.x from Cordova. I have asked Phonegap Support for verification and clarification on this forum post at nitboi
Need verification and clarification on phone-gap-version
http://community.phonegap.com/nitobi/topics/need-verification-and-clarification-on-phone-gap-version?rfm=1
I will update after they respond.
TIA
Jesse
I have a Phonegap app that I am developing and I would love to be able to tell the difference between one built on their server and one built locally on my machine.
Is there anything in the DOM that might give this information away?
Found a solution, whilst its not with the DOM its the only way I can see of checking which version I am in...
$.ajax({
url:'file:///android_asset/www/icon-72-2x.png',
type:'HEAD',
error: function()
{
//file does not exists
},
success: function()
{
//file exists
}
});
Only works with Android, but paths can be changed to match iPhone and the other devices as well.
I am trying to work with Meteor. Now I have the entire setup running in my localmachine with apache2 and the meteor.js also works when browsing the same URL from Android Emulator's Browser . Now the main problem is that I need the functionality in my android app from a local URL and here the page is not able to load the remote js. I am loading the following html using WebViews loadURL method after setting the javascript as enabled .The js embedded in the html will be something like this
<script type="text/javascript" src="http://meteor.mywebserver.com/meteor.js"></script>
<script type="text/javascript">
window.onload = function()
{
Meteor.host = "meteor.mywebserver.com";
alert(textStatus);
// Call the test() function when data arrives
Meteor.registerEventCallback("process", commentsUpdate);
// Join the demo channel and get last five events, then stream
Meteor.joinChannel("demo", 0);
Meteor.mode = 'longpoll';
// Start streaming!
Meteor.connect();
// Handle incoming events
function commentsUpdate(data)
{
alert(data);
};});
After searching around a lot I tried this stackoverflow answer
To no avail . Can anybody help me find a work around here , I cant use a local meteor.js as it wont work.
Thanks
This has since been addressed in Meteor by way of integrated Cordova, which you can read about here. Basically, you tell Meteor that you want to add the Android platform to your app, and it builds the Android project files for you. Your app will look as if it's running native, but it's really just running in a light app surrounding a "web view". In iOS this is done using WebKit, but I think in Android it depends on the version of the OS.
You will still need to deploy your app to the Play store, which requires signing the app and all.