Thursday, December 19, 2013

Xamarin Course on 8-10 Jan 2014 Confirmed!

I am happy to announce that the MOB101 - Xamarin Course on 8-10 Jan 2014 is now confirmed!

Using the Xamarin Studio, you can now create compelling Android and iOS (iPhone and iPad) apps using C#. Best of all, you can share your application logic  between the two platforms. And when you are ready, you can easily port your application to Windows Phone 8 (using Visual Studio)! And did I mention that your app developed will be a native app and a first-class citizen on the platform?

On 8-10 Jan 2014, I will have the 3-day course on using Xamarin to build iOS and Android apps. This course covers both iOS and Android development. As such you need to bring along your own Mac, as the testing needs to be done on the iPhone Simulator, which requires a Mac.

For those of you who want to know about the power of Xamarin, check out my article on the Jan/Feb issue of Code Magazine!

Wednesday, December 18, 2013

The Pebble appstore is coming to a smartphone near you!

The Pebble appstore is coming to a smartphone near you! Arriving in early 2014, you can now download your favourite Pebble apps through the Pebble appstore. 

Now is the time to crank up your development engines and write apps for the Pebble. Join our inaugural Pebble programming course on the follow dates:

* 6-7 Jan 2014 (Mon-Tue)
* 6-7 Feb 2014 (Thu-Fri)
* 10-11 Mar 2014 (Mon-Tue)

See you at the course! All participants will get a Pebble watch worth US$150!

Android Bluetooth Low Energy Programming course on 26 Dec 2013 confirmed!

I am happy to announce that the Android Bluetooth Low Energy Programming course on 26 Dec 2013. You will get a unit of the Ti SensorTag, which allows you to write an Android app to read the various sensors embedded within it. For more details, check out the course outline here.

Tuesday, December 10, 2013

PHP Tip - Redirecting to Another Page

There are times where you need to redirect the user to another page. For example, after the user has successfully registered as a user at your site, you might want to redirect them to the login page. As such, you need to be able to programmatically redirect the user to the target page.

To redirect the user to another page using PHP, you can use the header() function, like this:

header('Location: anotherpage.php');   
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">

This snippet of code must be placed at the top of the document, before the DOCTYPE element. The above code will automatically redirect the user to anotherpage.php whenever the user loads it.

However, if you want to programmatically redirect the user based on certain conditions (such as user successfully registering at your site), you have to do a little more work. The following code snippet redirects the user after injecting a delay of five seconds:

//--redirect to another page---
$delay = 5;  //---five seconds---
$redirectPageUrl = "login.php";
header( "Refresh: $delay; url=$redirectPageUrl" );
echo "You will now be redirected to the login page, after $delay seconds.";

The above snippet of code will redirect the user to the login.php page. Be aware though, that the above snippet must be accompanied by the following snippet, placed at the top of your PHP page:


The ob_start() function turns the output buffer on so that no HTML code is sent to the client until the entire PHP script has been processed. If you don’t do that, by the time the header() function performs a redirection it would be too late as HTML code has already been sent to the client. 

Sunday, December 08, 2013

PHP and MySQL Course on 19-20 Dec 2013 confirmed!

If you have always wanted to learn web programming, this is your best chance! The PHP and MySQL course on the 19-20 Dec is now confirmed!
You will learn how to write web applications that contains features like online voting and shopping carts.

Android Course on 23-24 Dec 2013 is now confirmed!

For those of you who are considering attending the Foundation of Android Programming course on 23-24 Dec 2013, you would be delighted to know that it is now confirmed! 

We will be covering Android 4.4 and be sure to bring along your own devices for testing!

Android Tip - Saving Instance State

One of the characteristics of an activity that it is automatically destroyed and recreated whenever there is a change in device orientation. As such, it is important that you take note of this so that you don’t lose any data when the user accidentally rotates the device.

When an activity is rotated, the activity will fire the onSaveInstanceState() method before the activity is destroyed:

    public void onSaveInstanceState(Bundle outState) {

        //---save whatever you need to persist—
        outState.putString("str", "This is a string!");

You can make use of the Bundle object to save the state of your activity.

Do not confuse the onSaveInstanceState() method with the onPause() and onStop() methods, as:
·       The onPause() and onStop() methods are always called when an activity is sent to the background or is being destroyed
·       When an activity is being destroyed, the onSaveInstanceState() method will not be called; it will however be called when the activity is sent to the background
·       The onSaveInstanceState() method will be called when it is being killed by the OS due to a memory crunch

When the activity is created, you can use the onRestoreInstanceState() method to restore the previous saved state of the activity:  

    public void onRestoreInstanceState(
    Bundle savedInstanceState) {

        //---retrieve the information persisted earlier---
        String s = savedInstanceState.getString("str");
        Toast.makeText(this, s, Toast.LENGTH_LONG).show();

While usually you can also use the onCreate() method to restore the activity state, the onRestoreInstanceState() method is another method for you to restore the activity state.

Thursday, December 05, 2013

Android Tip - Transferring File via Bluetooth

If you want to easily transfer a file from your application to another Android device, you can make use of Bluetooth.

Beginning with Android 4.1, you can now make use of the built-in Bluetooth Sharing app available on the device. The following code snippet shows how to use an Intent object to manually invoke the Bluetooth Sharing app to send an image from one device to another:

import android.content.ComponentName;
import android.content.Intent;
import android.os.Environment;


        //---assuming you have a file named MyPhoto.jpg in
        // your SD card---
        File file = new File(
            getPath() + "/MyPhoto.jpg");
        Intent i = new
            new ComponentName("",                         
        i.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));


Wednesday, November 27, 2013

Announcing the details of the Pebble Programming course

I am super excited to announce the details of the first Pebble Programming course held in Singapore. Here is the synopsis of the course and the dates:

Pebble Watch included in course fee!

In this 2-day workshop, you will learn the fundamentals of programming the Pebble watch. You will learn the difference between a Watchapp and a WatchFace app, and how to develop compelling Watchapps and WatchFace apps that you can install onto your own Pebble Watch. You will also learn how to write iOS and Android apps that interact with your apps on the Pebble watch. 

Setting up the Pebble SDK
WatchApp vs. WatchFace apps
Hello, Pebble World!
A Quick Introduction to the C Programming Language
Anatomy of a Pebble App
    Header Files
    Static and global variables
    Initializing the UI of the app
    De-initializing the app
Building User Interfaces
    Event Handlers
    Click Handlers
    Timer Handlers
    Navigating Windows
    Simple Animations
Persisting Data
    Writing to persistent storage
    Reading from persistent storage
    Deleting a key from persistent storage
Using the Pebble Accelerometer
    Using the Accelerometer Service
    Registering for Tap events
Integrating with Mobile Apps
    Using the PebbleKit for iOS and Android
    Connecting to your Pebble
    Obtaining information on Pebble
    Communicating with a Pebble app
    Launching and Killing your Pebble app
    Sending and Receiving messages
Integrating with JavaScript
    How to get your Pebble App to communicate with your JavaScript code running on the Pebble Mobile App on your mobile device
    Passing messages from Pebble to JavaScript
    Passing messages from JavaScript to Pebble

    Launching configuration page to let users customize your Pebble app

What you need to bring for the course?
    a. Need to bring along a Mac for the course
    b. Bring along your iOS or Android device

Time and Dates
9am to 5pm:

* 6-7 Jan 2014 (Mon-Tue)
* 6-7 Feb 2014 (Thu-Fri)
* 10-11 Mar 2014 (Mon-Tue)

* S$1,295 (nett; no GST) 
* Course fee includes a Pebble Watch (US$150)

Bayview Hotel Singapore
30 Bencoolen Street 
Singapore 189621

Application Form
Download Application Form here.

Monday, November 25, 2013

Wednesday, November 06, 2013

New Course - Pebble Programming! Coming soon!

I am super excited to announce of an upcoming new course on Pebble Programming! Ever wanted to create apps and watch faces for the Pebble? Now you have the chance!

Watch this space for details and schedules. For this course, a Pebble is required. No Pebble? No worries! Pebble watches will be provided for this course and you get to keep one for yourself after the course!

Get a Bluetooth Low Energy (BLE) SensorTag when you sign up for the Bluetooth Low Energy Courses

For those of you signing up for the Bluetooth Low Energy Courses (AND303 – 1-Day Advanced Android – Bluetooth Low Energy Programming and IOS301 – 1-Day Advanced iOS – Programming iBeacon in iOS7 using Bluetooth Low Energy), you will get a unit of the Ti SensorTag

The Ti SensorTag is a Bluetooth Low Energy (CC2541) device containing 6 sensors:

  • temperature
  • humidity
  • pressure
  • accelerometer
  • gyroscope
  • magnetometer

In the 2 courses, you will learn how to write iOS or Android apps that talk to this device to obtain the various values from the sensors. 

Wednesday, October 30, 2013

Check if your Android device supports Bluetooth Low Energy (BLE)

If you want to know if your Android device supports Bluetooth Low Energy (aka Bluetooth LE; sometimes also known as Bluetooth Smart or Bluetooth 4.0), download the checker application that I have created here. You can click on the link using a web browser on your Android device and it will automatically download the app onto your device. Just install it once it is downloaded.

This application will allow you to know if Bluetooth LE is supported on your device. You can also optionally email the results to me so that I can collate a list of devices that supports Bluetooth LE.

Want to learn how to program Bluetooth LE on your Android device? Join us in this upcoming course on Advanced Android – Bluetooth Low Energy Programming.