Showing posts with label android. Show all posts
Showing posts with label android. Show all posts

Sunday, May 27, 2012

Android App Inventor - More SMS Services

Since I wrote my last tutorial about using SMS services in AppInventor I have had a number of questions on the post which I thought I would expand on here.

I have added a some additional logic to the SMSTest application that will display the text message on the screen.



To achieve this I added a Label to the form called lblMessageReceived. When the phone receives a text message it will be displayed here.



I changed my IF blocks to a IFELSE block and included a block to set the lblMessageReceived.Text to the value of Message1.messageText if the messageText is NOT 'Status?'.


The image above shows the application running on emulator 5554 receiving a message from emulator 5556. You can see the label showing the contents of the text message.

This also shows the use of two running emulators to test communication application. The number in the title bar is the phone number of the emulator. This makes it very easy to test SMS applications.


I hope this tutorial has been helpful. Please feel free to comment if you need further information.

I have added a link to the source code here.

My other App Inventor tutorials:
App Inventor - Location Services
App Inventor - Lists
App Inventor - SMS Services
App Inventor - TinyWebDB Tutorial Source
App Inventor - TinyWebDB Part 2 - Web Service Source

Wednesday, August 17, 2011

Android App Inventor - MIT Center for Mobile Learning

Google announced today that Google App Inventor will be a key part of the MIT Centre for Mobile Learning. MIT will take stewardship of the project and will actively develop and promote the service as a teaching tool.

Given the track record MIT have with open source software this is good news for the App Inventor community.

Thursday, August 11, 2011

Android App Inventor - Closing Down

With the winding down of Google Labs, Google has announced that Android App Inventor will no longer be supported by Google and will be converted to an Open Source application.

The service will remain available until at least the end of the year, however the URL will change in the near future. The viability of the product will depend on a benefactor taking control of the project and providing hosting.



Wednesday, May 11, 2011

Google I/O 2011 - Keynote Day 1

For those developers not able to attend Google I/O 2011, here is the link to the Keynote for Day 1.

So far Google has announced:
More to come...

Tuesday, April 5, 2011

Android App Inventor - TinyWebDB

The next post in my series on Android App Inventor makes use of one the 'Not for Primetime' components. The TinyWebDB component allows you to store data on a web service. This means that the data can be accessed by the Android phone as well as a web application.

For testing purposes Google have provided a test web service at http://appinvtinywebdb.appspot.com/.  This service is a limited service and will only store 1000 entries. Due to these limitations it should NOT be used for your applications. Google provides instructions on how to create your own web service using Python and the Google App Engine.

The following example uses the application I built for the Android App Inventor - Lists post. This post will show how to store the contents of a list to the TinyWebDB web service and also retrieve the contents of a list from the TinyWebDB web service.


To begin we need add two buttons (btnStoretoWeb & btnGetListfromWeb).



We also need to add the TinyWebDB component. I have also added a Notifier component to allow us to return a message to the user when the data is stored.

 The TinyWebDB1 control needs to have the ServiceURL set to the debug URL: http://appinvtinywebdb.appspot.com/


Once the GUI has been configured we start the block editor and create the logic to save the list to the TinyWebDB.

To store a value on the web service we add the btnStoretoWeb.Click event. Within the event we call the TinyWebDB1.StoreValue method. This method has two parameters. The 'tag' parameter allows you to assign a key to the data. The second parameter is the list you are going to store.

The second event shown above is the TinyWebDB1.ValueStored event. When a value is stored in the TinyWebDB this event is triggered. I have used it to provide a notification to the user that it worked.

The next step is to retrieve the values from the web service and repopulate the list. In this case I have used a button to manually trigger the load of the list. In a production application you may want to put this code into the Screen.Initialize event.

In the btnGetFromWeb.Click event we call the TinyWebDB1.GetValue method with the name of the 'tag' we want to retrieve. In this case it is the MyStoredList tag.

Once the GetValue call is sent we need to wait for the TinyWebDB1.GotValue event to be called. This ensures that our application can remain responsive even if the call to the web service is slow to respond. When the event is triggered the application has access to the parameter valuefromWebDB. This contains the list we stored previously.

We can then store this value into the list. We also update the label to show the number of items in the list. I also load the ListPicker1 component.

I hope this tutorial has been helpful. Please feel free to comment if you need further information.

I have added a link to the App Inventor source here.

My other App Inventor tutorials are:
App Inventor - Simple SMS
App Inventor - Location Services
App Inventor - Lists

Friday, March 4, 2011

Android App Inventor - Lists

This post will explain the use of lists and list controls in Android App Inventor.

There are three parts to this post. In the first part I will examine how to create a list and add items to the list via the GUI, the second part will show how to make use of items in a list directly and thirdly I will show how to link a list to a GUI list control to select and display items.

To create a list we go to the Block Editor and define a new variable called 'list'. We can then call a 'make a list' method which will create a blank list.





In the GUI add a textbox and button. The textbox will be where you add the value you want added to the list. The button will call the btnAddText.Click event to add the text in the textbox to the list.

The code will also update the label underneath the button to show the current number of items in the list.

The next step is to make use of this list. In the screenshot below I have added a button and a label to the screen.  The label is not visible as it is empty at the moment.

When the button is selected on-screen the btnRandom.Click event is called. This event will randomly select one of the list items and display it in the label. The call to the random function is surrounded by an IF block to ensure that the list is not empty.

Finally, the last thing to do is associate this list with an on-screen control that we can access to select items.

On the GUI a ListPicker control has been added. We also add a Label to show the returned value.

This control will display a list of values and when the user selects one it will return the value back to the user. To associate a List with a ListPicker control we call pass the list into the ListPicker.Elements method.

In our example this is done as part of the btnAddText.Click method. This ensures that the list control is updated each time an item is added to the List.

Now that we have associated the list to the ListPicker control we can use a ListPicker.AfterPicking block to show the returned value on the Label.

The following is some screenshots showing the overall GUI design with the names of the controls.


I hope this tutorial has been helpful. Please feel free to comment if you need further information.

My other App Inventor tutorials are:
App Inventor - Simple SMS
App Inventor - Location Services

Thursday, February 24, 2011

Android App Inventor - Simple SMS

Recently, I have been doing some further development on Android App Inventor. My focus for this work was getting the application to send and receive SMS messages. To aid others in doing this I put together this tutorial which shows this.

The first part of the tutorial shows how to send an SMS from within an App Inventor App. This is relatively simple and requires a a couple of text boxes (Mobile Number & Message Text) and a button to press to send the message.

You will also need to add a non-visual Texting component to the form. 



Once the form has been created, the Blocks required to send a message should be configured as in the following image.


This block of code is executed when the user clicks the Send Message button. The first two actions are to set the Mobile Number and Message text on the Texting object to the values in the text boxes.

The last action calls the Texting.SendMessage method to actually send an SMS. Simple.

Note: This code does not do any error checking or validation. Erroneous data may cause the application to Force Close.

The second part of the tutorial will show how to make an App Inventor application respond to an SMS that it receives. For this application there is no GUI as the application handles the logic in the background. All we need are some blocks to intercept the SMS messages received.



This block of code is executed when the phone gets a SMS message.

The MessageRecieved method exposes two values: number and messageText. You can store these in a couple of variables.


The second thing this block does is to check the message to see if it contains the text 'Status?' If this text is in the message it will create a new TextMessage using the received number and respond with the message 'All Good!'. This is a simple application for this but could be used for such things as responding with a user location or responding with a simple message if the user is unavailable.

I hope this tutorial has been helpful. Please feel free to comment if you need further information.

I have added a link to the source code here.

My other App Inventor tutorials:
App Inventor - Location Services
App Inventor - Lists

Sunday, November 7, 2010

Endomondo Android Application

In previous posts here and here I documented how I use GPS enabled mobile phones to record my mountain bike rides. I have recently been evaluating Endomondo. Endomondo is an Android application which records your rides, runs, swims, and any other exercise.

The Endomondo service consists of a mobile application (Android, iPhone, Blackberry and Symbion) that makes use of the GPS functionality of the phone to track your workouts. This is paired with a web-based service that will store a history of your workouts along with allowing you to see your workouts overlayed on a Google Map.

Some of the key features of the Endomondo service which make it interesting to use are:

  1. Audio Coach: the Audio Coach uses the text to speech functionality on your Android phone to announce your current progress at each kilometer. It means you do not need to constantly check your progress on your phone.
  2. Live Tracking: if you have a mobile connection active on your phone, the application will constantly update the web service with your progress. This will allow interested people to follow your progress via your profile page. An interesting addition to this is the ability for someone to send a message to your device which will then be read out by your device.
  3. Routes: if you have a favourite ride/run this can be published as a route on the web service which means that anybody can ride/run this course and compare their times to yours. 

Overall, the application and web service work together very well. The workout history is reasonably comprehensive and the statistics collected can be used to see how many kilometers are ridden in a year.

Sunday, October 17, 2010

Android App Inventor - Location

I recently got a new HTC Desire phone. One of the main reasons for purchasing an Android phone was the ability to write and deploy my own applications to it. Just prior to getting the phone I had seen a post from Google regarding the new App Inventor for Android tool. The tool is in beta at this time so I signed up hoping that I would get an invite and I would be try out this new tool. Last week I got the invite and started playing with App Inventor.

As I am interested in GPS and location aware applications I decided to develop a small application that would show the current location, current address and the option to launch the Google Maps application on the phone.

 The Android App Inventor is a web application that has a visual GUI builder to create the GUI and uses 'blocks' in place of code to provide the logic in the application.

The screenshot below shows the GUI builder with the 4 controls used to display the current latitude and longitude and the street address if known from the Google geocoding service. It also has a button to initiate the display of a Google map centered on the current co-ordinates.

To obtain the GPS co-ordinates you will need to add a LocationSensor to the non-visible components. This sensor allows you to access the built-in GPS on Android devices. It includes methods to enable/disable the internal location sensor, read the sensors and get the current address.

The next screenshot shows the logic required to display the latitude, longitude and address on the screen whenever the phone is moved.

It also shows the logic for the ActivityStarter to create and display a Google Map. Information on how to setup the properties for the Google Maps ActivityStarter is in the MapTour tutorial.



Once the properties are configured you will need to generate the URI to pass to the Map Activity. I have shown this above as it took a couple of attempts to get this right. As it is not currently possible to simulate the location sensor in App Inventor the app will need to be compiled and deployed to either the Android SDK emulator or a real phone.I did this a number of times prior to getting it to work.

I hope this information helps if you are trying to use LocationSensor and Google Maps activities on App Inventor.

I have added a link to the source code here.

My other App Inventor tutorials are here:
App Inventor - Lists
App Inventor - SMS Services

Sunday, September 12, 2010

HTC Desire - Android Phone

Two weeks ago I got myself a HTC Desire. For the last couple of months I have been watching the release of various Android phones to decide which one I should get once my contract was up on my old Nokia. The winner was the HTC Desire. It was universally billed as one of the best Android phones available today.

I had decided to get an Android phone because as a developer I would like to be able to create applications for my phone. The other reason to get an Android rather than a iPhone (iOS) was that all the tools required to develop applications are freely available and run on Windows or Linux.

Over the coming months I will try to document my attempts at building some simple applications for the HTC Desire.

Sunday, May 23, 2010

Google I/O 2010 - Keynotes

Google I/O 2010 finished two days ago. Lots of interesting news for HTML5 and Android. Here are the two Keynotes from Day 1 and Day 2.



Tuesday, November 17, 2009

CNET Interview with Eric Schmidt from Google

An interesting interview with Eric Schmidt the CEO of Google. Discussions about Google OS, Google Search, Android and Google's motto of 'Do No Evil'.