These are my technologies,
- HTML5
- Jquery mobile, Jquery, Java Script
- Css
- Cordova
We are developing app using HTML 5 and we need to access phone (Android,iPhone,Windows Phone) resources, such as alarm (to create reminder). Questions,
- Can we access native resources of mobile phones through this technologies ?
- Do we need different coding to access different mobile operating systems ?
- What are the pros and cons of this method ?
- what is the Best method of doing this ?
- Any suggestions ?
Sample code or examples for access Android, Iphone and Windows phone 8 alarm manager through javascript?
Did any one use this Background Service Plugin for this task?
I asked question regarding this use for access alarm manager
do any one have sample code or give me a step by step guidance, how to use this for access Android alarm manager ?
I try to access native code through java script like this question and answer but it's not working.
When i clicked the button;
- in eclipse logcat; under cordova tag,
Uncaught TypeError:Object [object Object] has no method 'getTelephoneNumber'
- in eclipse logcat; under chromium tag,
[INDO:CONSOLE(22)]"Uncaught TypeError:Object [object Object] has no method 'getTelephoneNumber'", source: file:///android_asset/www/index.html (22)
my phonegap version is 2.7.0 and Emulator API level 19. what is the problem in here ? did i miss anything ?
After a long running process i manage to come up with solution to the android devices.
1) Access native code using javascript is possible
2) Using javascript interface raise a threat of xss vulnerability, but in Latest API Level 19 eliminated this. (Read more...)
Let the code speak; MainActivity code first
1) onCreate method code
2) To complete next step you need to have Reminder class with in your MainActivity class and what ever html file in your assets folder. In my case i have Login.html in assets/www/Phone/Login.html
3) Here is my Reminder class and its constructor
4)ReminderReceiver class
5) Method that can call through JavaScript and responsible to add Alarm object into System Alarm Manager. In Reminder class
6) Now, you need to edit your Android Manifest.xml
set permission,
And Register ReminderReceiver class, add this lines with in tag (not inside of any other tags !!!),
7) Finally in your html file add button, add javascript function, call it in button click event and inside of that function call addReminder method
Hope this answer will help who trying to using Native function of Android phone while developing through Phonegap
Answers:
1.Can we access native resources of mobile phones through this technologies ?
Yes, you can by using javascripts.
2. Do we need different coding to access different mobile operating systems ?
Yes, there isn't one size fit all.
3. Suggestions:
Check the document of each individual mobile system. You will find the guidelines as well as examples.