PhoneGap, Pedometer, and Intents

This week I spent some time updating the Pedometer branches that I was working on.  At first my Native-Pedometer branch had too many conflicts and errors after merging.  So much of the day was spent making my final commits and pushes to this old deprecated branch.  Next I checked out the DEV branch, made sure it worked and and then made the Native Pedometer II branch.  This all was working after checking on the phone.  This was the new branch I would work with from now until the next successful merge.  I would like to say thanks to Wei for his advice on how this complicated process works.  Next I made a pull request in my Bit Bucket repository so from now I can simply commit, push and make updates whenever.  This all been done, I wanted to now do some more work.  I feel that some way to connect the Pedometer to the Mobile Blue Tooth adapter could be through intents.  That way when a user clicks on a button a new activity is launched. Currently I am investigating this process and hope to solve this efficiently and creatively.  This is my task at the moment and is based on concepts I am researching and have learned in class previously.

Advertisements

BluGlu Code

After looking at the BluGlu code, it appears that while there is not much of a difference between the HTML and JavaScript of the BluGlu and AND, BluGlu has various additional features in native Java code. There are various files involving BluGlu including:

  • A connection between BluGlu and the BlueTooth client.
  • There are also classes which handle the creation of headers and packets for BluGlu.
  • Parsing of BluGlu packets.
  • A CommandFactory class for any BluGlu command.
  • Detection and timeout for messages.
  • An actual BluetoothCommand class.

Latest on the Pedometer

Last week was very interesting.  I was given an opportunity to present at the NEXJ Express booth at the CDOT Open House.  Many came and went.  Some stopped to ask questions about the work we do.  I was glad to answer the questions as challenging as they were.  At the end of this special evening I felt a great sense of achievement.

The next day Friday I spent time reviewing the Pedometer.  I have made some improvements that I think are important.  Such as:

Pedometer running
Pedometer running:  This is the first state, the pedometer is running
Pedometer paused
Pedometer paused: The user can pause their activity and the resume
Pedometer off
Pedometer off:  The user has stopped the Pedometer and all related step counting activities.
The user can only save their progress when the timer is enabled.  The next step is the pull request for the Pedometer.  Thanks for your time.

Java to JavaScript Migration

Regarding the possiblity of migrating native code from the Java library into JavaScript, the PhoneGap library seems to have support for interfacing with the device, for example, contacts. However, it doesn’t seem to have support for BlueTooth services. There seems to be several PhoneGap plugins that we may able to use to get the required BlueTooth support. More research is required on those plugins.

Demo MMDI – Back Button

Hi, I have added code so that when the user presses the back button on their phone while the Demo MMDI app is active, it goes back to the previous screen instead of exiting the app (which is default behaviour). On Screen 1, pressing the back button is equivalent to pressing the X in the top-right corner. On the About page and Screen 2, pressing the back button on the phone is equivalent to pressing the given back buttons on the app. On Screen 3, the back button does nothing since it does not make sense to back on the finished page.

Accessing Withings Web Api from Android

Dylan Segna

I had a lot of trouble getting Withings’ web Api access working in an Android application.
After getting in contact with one of the Withings Api developers, I was finally able to solve the issue.

The problem was that Withings unique OAuth implementation did not work as expected with the OAuth library I was using, Scribe.
After authenticating the user, Scribe was sending all the OAuth information in an Authentication header.
However, Withings was still expecting all this authentication information to remain in the URL query string.

Here’s how I worked around this issue:

This is the basic request sending code.

private Response sendRequest(String resource, String action){
        String URL = apiBase + resource;
	OAuthRequest request = new OAuthRequest(Verb.GET, URL);
	request.addQuerystringParameter("action", action);
	request.addQuerystringParameter("userid", userId);
	addOauthParameters(request);

        Response response = request.send();
	return response;
}

The resource and action parameters are based on what you are requesting.
They are gotten from Withings Api documentation…

View original post 94 more words

Week ending 15/11/2013

This week I spent my time upgrading the pedometer from Cordova 2.5.0 to 2.9.0.  The changes that are noticeable are in the config.xml file. Plugins are now known as features, and if you don’t use “android-package” you end up having problems.  So if your new to this it will take a while to make sure everything is working.  So with a bit of luck I had the Pedometer working by the evening and noticed that there are improvements that need to be made.  In my next blog post, I will post a picture of that Pedometer looks like.  I am no longer using using the jQuery available via HTTP, everything is now included whether you are online or offline.  Likewise for the CSS.  I look forward to continuing ‘servicing’ the pedometer this week already here.  It should be on demo with the rest of the Mobile Bluetooth adapter this Thursday at the CDOT open house.  So see you soon.