I'm developing a cross-platform mobile application using HTML5 Javascript & Phonegap. It's supposed to be an application which can display the Device Information and RAM & CPU status (using & free RAM CPU, name, size,...).
But I can find any API which can get the status of CPU&RAM. I'm just a beginner in Mobile HTML5&JavaScript. So, if you guys know anything that can help, please tell me. I'll be very appriciated.
Thank you!
In a plain web app you don't have access to this information. But since you mentioned Phonegap in your question, you can get basic device info using this:
http://docs.phonegap.com/en/3.0.0/cordova_device_device.model.md.html#device.model
There are also 2 cordova plugins which you can look into. Neither has iOS support at the time of this writing.
http://plugins.cordova.io/#/package/com.ankamagames.plugins.sysinfo
http://plugins.cordova.io/#/package/org.chromium.system.memory
You may want to look at Chrome packaged apps and the chrome.* apis for cross platform and mobile development here https://developer.chrome.com/apps/about_apps
Although I never worked on such area. But what I can suggest is- You will need to write android native plugin to achieve the same.
I think there should be android api to read memoryinfo and cpuinfo file if not you can directly read /proc/cpuinfo and /proc/memoryinfo to get ram and cpu related information.
Hope it will give you some insight. Below is the link of related question -
Android How do you get total memory RAM in the device?
Related
I have a WebApp built using HTML5, JS, Jquery - but I'd now like to build some Bluetooth functionality into it in order to transfer data to another BT enabled device.
I've downloaded the Bluetooth Dev Kit and read a lot of the papers, but seems that the tools available are for Native Apps.
Can anyone advise if there are BT Group approved libraries or add ins that I could use for the purpose.
Thanks
Phil
In practise, in 2016: No.
Support for the Web Bluetooth specification is practically nil.
Only Blink based browsers support it, and even then it is locked behind a user preference that defaults to off.
Brief overview of the app:
We had two(IOS Cordova & IOS native) working apps, We had a plan to integrate both the application with existing technical stack. We managed to Integrate successfully by converting the Cordova app into binaries with the help of cocoapods and integrated it into IOS native app, the app functionality is working fine.
In IOS native app we have more than one webviews.
Issue : In Cordova app sometimes we are loosing the data which is saved using "window.localStorage" this issue is not consistent but happens 2or3 out of 10 tries .
Above issue Occurs only in the Integrated version of app (Cordova + Native) and not in stand alone version of Cordova app.
We had the same kind of issue in integrated version (Android native + Cordova android) we managed to fix this issue by overriding the "windows.localstorage" using "addJavascriptInterface"
Questions :
1) Have anyone experienced the loss of localstorage value.
2) Do we have such option( ie "addJavascriptInterface" ) for IOS as well if so can you please explain how or can you suggest some other better option to commute between Cordova webview to the native layer
Note :This commute from Cordova webview to native IOS should be synchronous not asyn because I need to override the "windows.localstorage"
Used cordova version 3.6.3
Thanks in advance
Since iOS 5 the localstorage is not persistent.
The file of the localstorage is saved in the directory .../Library/Caches and this directory may be deleted by the OS if the system is very low on space. For more information about the file system in iOS see: File System Programming Guide
According to the documentation of cordova they mention the loss of data as a disadvantage of the localstorage: "iOS stores localStorage data in a location that may be cleaned out by the OS when space is required."
So in case you're running out of space the loss of data is not a bug.
Because of this problem we are looking for an alternative to localstorage, too.
After researching I've found a plugin especially for this problem. This plugin is using NSUserDefaults (iOS) and SharedPreferences (Android) to store the data permanently. This is actually my preferred solution for this problem.
Other ways out of this problem, that are suggested often are:
store the values in a file that's located within a persistent directory. This solution should work for all platforms with the file plugin.
using sqlLite. There are many plugins to provide this functionality.
I had faced same issue with some devices. There is one model out of about a dozen that we use that has similar issue. I store 6 objects (strings) in local storage and on these devices some of objects in unexpected moment may become null.
After digging stackoverflow I have found some similar cases that do not unambiguously answer the issue. For example, they reported:
localStorage cleared on app restart with Cordova 1.7 and iOS 5.1.1 — storage might not be saved if app was closed
Complete data loss Ionic / Cordova LocalStorage and Websql iOS 8.4.1 — storage might be cleared when device is low on space
https://stackoverflow.com/questions/27816556/cordova-windows-phone-localstorage-clear-on-app-update — storage might be cleared on app update
Also there were some references that some versions of PhoneGap may result in this issue.
So, there are no answers for me yet.
My own plan — to use files or SqlLite. I am sure that files that are stored with FileAPI are there and are not lost.
After deep-diving into the issue we managed to find out that the localstorage file is getting corrupted which result in loss of persisted data.
Solution which worked for us is : We started backing up the localstorage file via native layer of iOS. In our app we face this issue only when user navigate from Native stack to hybrid stack as the Native stack will always be the starting point of user`s transaction.
Note : We had integrated the Cordova app ( Cocoapods ) into Native app.
I was searching for how to use swf file in android and most of the answer suggested me to use webview and an simple html file.
Now i think We can easily put css and javascript files in asset folder and then we can use them in an html5 code.
Looking at the power of HTML5, This will make app development for a web designer very easy job !
I just want to know that is it good to use this approach to build a good user interface in android ? Are there any technical pros/cons behind it ? will i miss some features provided by android ?
There are a lot of frameworks that allow you to write native android applications using HTML/CSS/JavaScript only. Here some of them :
PhoneGap
Cordova
Titanium
I've never used any of them, so I can't say if it's good or bad idea to write android apps this way, but here you can find a good session about it HTML5 versus Android.
There are pros & cons of using cross platforms. As per my point of view you shouldn't go for loading of everything in WebView.
I still recommend you native app approach because of following points :
WebView is one of the UI control in Android SDK. So, it will have
limitation of memory size and working with CPU utilization. So, you
might face performance issues in some devices.
As you know in older era we were used to work with desktop apps and after that everything is shifted to web-application.
It was
possible only because our browser(s) gets more features for e.g. more
memory area, CPU access, threading, individual Processing (like
google chrome) etc...
in-short, web browsers gets more smart and get treated as separate application. Now a days web-application can have mostly similar
performance as desktop apps. So, everything is now shifted to
web-application development.
This era will come in to Mobile development in later stage. but currently we are in middle stage of Mobile development and Cross platform development. So until and unless Web-View control of any platform (iOS / Android) gets more powerful, we can not totally relay on that.
I Hope I explain it properly :)
I was looking all over and couldn't get a direct and clear answer. Is it possible to sign a document from Javascript code running in a web application (Safari)? I wish to use a certificate from the iPhone built-in certificate store.
I found a similar post which was not answered: Working with certificates in web applications for Apple iOS
Thanks!
Yoash
Just been looking through some older questions (just in case somebody else stumbles across this) and I can say that No, this is definitely not possible. The only way to achieve something along these lines would be to create a phonegap plugin which handles this for you and distribute your web application as a phonegap application.
I'm starting to try and do some web based game programming for my iPhone, and other web enabled phones that my friends have, and was having a hard time finding information on accessing the accelerometer using Javascript in the browser.
With the latest release, I know I've got access to location information now but I was hoping that I could make use of the accelerometer for some of the games I plan on making.
Alternately, is this also possible with the Android phones?
In the latest iOS update (4.2) the accelorometer is now accessible from Javascript.
See: http://www.mobilexweb.com/blog/safari-ios-accelerometer-websockets-html5
iOS 4.2 provides Accelerometer & Gyroscope support through the DeviceOrientation API.
DeviceMotionEvent class
reference
DeviceOrientationEvent class
reference
Here a working javascript snippet.
If your are using iOS 4.2 or more, then you can do it: http://www.albertosarullo.com/blog/javascript-accelerometer-demo-source
jharlap is correct, however I'd be curious to know if this would work on the Palm Pre. Native development on the Pre is done using html and JavaScript, however there are special JavaScript APIs to access the phone's features that I believe only work for locally stored apps. I wonder if these are available through the browser. I doubt it, but it would be interesting.
Checkout PhoneGap project. It provides API to access the accelerometer and the GPS location from javascript.
"Regular" javascript cannot access the accelerometer info, it can access the geolocation using the W3C geolocation API supported by iPhone OS 3.0.
Yet, a project (e.g. PhoneGap) can be used to build a bridge between javascript and Objective-C capabilities to expose that functionality. This works if you want to deploy the app as a standalone application, that simply has one WebKit which loads the html content from the server.
I haven't played with their framework, but they provide templates for the iPhone and Android projects and you can work on developing your javascript game which would work almost-out-of-the-box on iPhone and Android. I cannot comment on the performance and the user experience though.