Input file properties are blank in mobilefirst app - javascript

I have a hybrid app in IBM Mobilefirst platform. There is a file upload feature which uses
<input type='file'>. In the javascript code, the file object parameters like file.size are blank when uploaded from mobile device. Working correctly when previewed from desktop browser. Any clue what is wrong?

You do not have access to the filesystem from pure JavaScript in a mobile application, that is why it does not work you.
When you preview your app in a browser, you're in a browser. A desktop browser does have access to the file system and that is why it works for you.
In order to do any operations on the filesystem in a mobile application you need to use native code (which will obviously not work in a desktop browser).
So either you implement custom native classes, or use Cordova APIs.
It sounds like you need to refer to the Cordova File API: http://docs.phonegap.com/en/3.3.0/index.html
Note: Cordova is bundled in a MobileFirst Hybrid application, so you need only to implement the functionality with the provided APIs.

Related

cordova - call javascript from android background service cordova plugin

Currently, I am developing an Ionic2 app that should have an ability to connect automatically to paired bluetooth devices in range while beeing closed/killed in order to collect specific data.
Using this plugin https://github.com/Red-Folder/bgs-core, I am creating a background service for android.
Since most of the main app logic written in JS, I would like to know whether it is possible to call functionality written in JavaScript from cordova plugin (in case of Android from Java) while the application is closed. If yes, how can I do it?
As an alternative, are there other cordova plugins that support background execution while an app is killed?
I have found similar questions, however, none of them contains a sufficient solution:
run javascript in background service on android phonegap
How to run cordova plugin in Android background service?

Can I have a directory chooser in an Android application using phonegap?

I know that html/javascript doesn't give a directory chooser for security reasons ,but what if I'm using phonegap to create an android application ,means I will create this application using html and javascript ,I read phonegap file API but I couldn't figure out a way to do that ,is there any example does the same ?? Any help would be really appreciated ...
there is reference link you may get answer
PhoneGap's File API
Mobile File Explorer with PhoneGap/Cordova and

mobile web app HTML and JavaScript file location

I'm new to mobile web app development. I have a simple fundamental question regarding mobile web app. Mobile web app is written in HTML and JavaScript. So are these HTML and JavaScript files stored on the mobile device locally or sent from a server? This question may be too simple for most people. But I ask this because if all JavaScript code is stored on mobile device, then how about cross domain access issues? Thanks.
It depends. If you package it in PhoneGap you will have all your assets stored in a single package that can be installed in multiple devices, but if you're working on a mobile web app thats served from a remote server, all the scripts, templates and css's will have to be downloaded. If you're having issues with cross domain comunications, try using JSONP in your requests.
All the files are downloaded each time you request certain url, for mobile devices and pcs as well.(the file will be downloaded or not depending on the caching setting, if the file was modified, etc)

Create a app by using java script on Android for multiple devices

I have an HTML app which calls some functions from JavaScript files, and the JS files make some AJAX queries and get JSON objects in response.
I have to make a similar app on Android which can be run on multiple devices (Android), by using the same JS files. In other words, I have a JavaScript API, and I have to use this API to make the app on Android.
I have some queries:
Would it be feasible by using WebView (considering it's a big app not a small app)?
Should I use PhoneGap?
Please let me know how could I do this and welcome to some more suggestions.
Answers :
Yes , Using Webview you can build application using HTML + Java Script
Its depend upon you applications functionality and usage of your application. If you want to make your app Cross Platform like (Android , IOS ) You should try out Phonegap.

is Phone Gap capable of converting a php web app into an iphone/android app?

Does anyone use PhoneGap?
I have a php app which uses ajax to receive json data. This technology called PhoneGap http://www.phonegap.com/,
is it able to convert my php app into an iphone/android app?
I know that if it is simply a javascript / html / css app that does not require server side technologies Phone Gap is capable.
However I definitely require the internet access and ajax connection to online web services.
Does anyone use PhoneGap?
Yes.
is it able to convert my php app into an iphone/android app?
PhoneGap does not "convert" anything. You can convert your "php app into an iphone/android app", and PhoneGap might be part of your solution.
You would start by getting rid of all the "php" -- if your "app" can run purely in a browser using local storage, it will almost assuredly work with PhoneGap. PhoneGap also supplies some PhoneGap-specific JavaScript APIs, which you may or may not need.
However I definitely require the internet access and ajax connection to online web services.
PhoneGap neither helps nor hurts here. PhoneGap wraps around the Android WebView widget, which is itself based on WebKit, the same rendering engine used by Chrome, Safari, etc. If, after you get rid of your "php", your "app" works in Safari and Chome, it should work as "an iphone/android app" with PhoneGap, with some adjustment to your HTML/CSS/JS to deal with smaller screen sizes, touchscreens, etc.

Categories