Thursday, March 20, 2014

Android Tip - Displaying Notifications

In Android, a good way to notify the user outside of your application is through posting a notification in the notification area of the device. The notification will appear until the user opens the notification drawer and taps on it. Usually, tapping the notification will launch the application that displays the notification.

To create a notification, use the NotificationCompat.Builder class to create a Notification object, as shown in the following method:

    private void postNotification(String title, String msg) {
        //---which activity should be launched when the
        // notification is tapped---        
        Intent resultIntent = new Intent(this,
            MainActivity.class);
        PendingIntent pendingIntent =
                PendingIntent.getActivity(
                this,
                0,
                resultIntent,
                PendingIntent.FLAG_UPDATE_CURRENT
            );       
       
        //---create a notification---
        Notification notification = new
            NotificationCompat.Builder(this)   
            .setSmallIcon(R.drawable.ic_launcher)
            .setContentTitle(title)
            .setContentText(msg)
            .setAutoCancel(true)
            .setContentIntent(pendingIntent)
            .setNumber(1)
            .build();
       
        //---set the sound and lights---
        notification.defaults |= Notification.DEFAULT_SOUND;
        notification.defaults |= Notification.DEFAULT_LIGHTS;
       
        //---display the notification---
        notificationManager.notify(
            NOTIFICATION_ID,
            notification);       
    }

Each notification is identified using a notification id. Posting another notification using the same id replaces the previous notifications. You also need to use the NotificationManager class to post the notification:

public class MainActivity extends Activity { 
    private static final int NOTIFICATION_ID = 123;
    NotificationManager notificationManager;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
       
        notificationManager = (NotificationManager)
            getSystemService(
                Context.NOTIFICATION_SERVICE);
    }

You can now post a notification by calling the method that you have just defined:

        postNotification(
            "A sample notification",
            "Just testing the notification...");  


Monday, March 17, 2014

Foundation of Pebble Programming - 7-8 April 2014


The next run of the Foundation of Pebble Programming course would be held on the 7-8 April 2014. Come and learn how to write interesting apps on your Pebble watch. You will also learn how to write Javascript code that communicates with your Pebble watch. Once you learn that, you will be able to write apps that tells your location, displays stock prices, and more!

The fee of S$1,295 includes a Pebble watch! Download course brochures and application form here. 

Tuesday, March 11, 2014

Schedule for April to June 2014 posted!

I have just posted the new schedule for courses from April to June 2014. Check out the link here for the list of courses. There is something for everybody!



Wednesday, March 05, 2014

HRD101 - Getting Started with Raspberry Pi - 9 April 2014

I am pleased to announce that the next run of the Raspberry Pi course is on 9 April 2014.


Based on feedbacks from the previous runs of the course, we have put in more focus on hardware-related projects, such as:

    * How to build your own CCTV surveillance using a Webcam
    * How to build an iBeacon
    * How to detect motion
    * How to connect to a LCD display to display Twitter feeds

In addition, we will also cover how to set up your own Web server using Apache and PHP!

Venue
Bayview Hotel Singapore
30 Bencoolen Street 
Singapore 189621
9am to 5pm

Fee
S$699 (nett; no GST)

Date
9 April 2014 (Wed)



Download course outline and application form here.

WEB102 – 1-Day Developing HTML5 Web Applications - 20 March 2014

The next run of the HTML5 programming course is on 20 March 2014.

HTML 5 is the new standard for the venerable HTML specification, a standard for displaying Web content. HTML has come a long way, going through a number of revisions - with the last version - 4.01, recommended by the W3C in 1999. The design goal of HTML 5 is to ensure that an application that you write can work on all browsers without the need to install additional plug-ins. It should be able to do everything from animation, to music and videos, local storage, offline applications, and more. HTML 5 is also cross platforms, meaning that your apps should be able to work whether it is run on a notebook, smartphone, tablet, or desktop computer.

In this 1-day course, you will be able to understand and use the new features of HTML5 through working with practical examples.

Topics

•          Quick Introduction to HTML
•          Crash Course in JavaScript and CSS
•          Using Canvas for drawing graphics    
•          Using SVG (Scalable Vector Graphics) in your HTML 5 pages
•          Implementing drag-and-drop in your Web Pages
•          Implementing LBS (Location-Based Services) in your Web applications
•          Embedding audios and videos in your Web pages
•          Using different input types in your Web pages
•          Using Web storage in HTML 5
•          Creating offline Web applications
•          Creating responsive Web applications using Web Worker
•          Implementing notifications in your Web applications through server messaging

Venue
Bayview Hotel Singapore
30 Bencoolen Street 
Singapore 189621

9am to 5pm

Fee
S$699 (nett)

Dates
20 March 2014 (Thu)

Download course outline and application form here.

Sunday, March 02, 2014

Android Tip - Detecting if your App is in the Foreground

Very often, your application will continue to work in the background. When an event occurred (such as entering an iBeacon region),  you might need to inform the user about it. If the application is in the foreground, you can use the Toast class to display a message. If the application is in the background, then a more persistent form of notification is needed, such as using Notification messages. In either case, you need to programmatically check if the application is running in the foreground or background when the event occurred.

Declare the following method named isAppInForeground() in your activity:

    //---helper method to determine if the app is in the
    // foreground---
    public static boolean isAppInForeground(Context context) {
        List tasks =
            ((ActivityManager) context.getSystemService(
             Context.ACTIVITY_SERVICE))
             .getRunningTasks(1);
        if (tasks.isEmpty()) {
            return false;
        }
        return tasks
            .get(0)
            .topActivity
            .getPackageName()
            .equalsIgnoreCase(context.getPackageName());
    }

In order for the method to work, you need to add the GET_TASKS permission in your AndroidManifest.xml file:

    <uses-permission
        android:name="android.permission.GET_TASKS"/>

To check if your app is in the foreground, simply call the isAppInForeground() method:

        if (isAppInForeground(getApplicationContext())) {
            Toast.makeText(this, "App is in the foreground",
                Toast.LENGTH_LONG).show();
        } else {
            //---create notifications, etc---       
        }


If the apps is in the background, you might want to create a notifications, etc, to inform the user.

Monday, February 24, 2014

Foundation of Android Programming - 5-6 March 2014


Come and join us on the 5-6 March 2014 where you will be able to learn how to get started in writing your first Android 4.4 applications. You will learn how to create interesting Android apps that:
* Connect to Web services
* Launch other apps
* Obtain user's location 
* Display Google Maps
* Send and receive SMS messages
* Save data to files and databases
* and more!

Venue
Bayview Hotel Singapore
30 Bencoolen Street
Singapore 189621

Fee
S$997 (nett; no GST)

Download course brochure and application form here. 

Pebble course on 10-11 March 2014

For the Pebble course, on the 10-11 March 2014, you are recommended to bring along a Mac if you have one. If you don't have a Mac, you can bring along a Windows machine loaded with VirtualBox. This is because the SDK for the Pebble is Unix-based, and hence a native version of the SDK is not available for the Windows platform. As such, if you have a Windows machine, you will use VirtualBox to run Ubuntu (a version which I have prepared) and run the SDK on Ubuntu.


As for mobile device, you are required to bring along a mobile device (iOS devices strongly recommended). If you don't have an iOS device, you can also bring along your Android device. The reason for this is that the Pebble mobile app is currently in beta for Android, and it still has some minor issues in terms of stability. The Pebble mobile app for iOS, on the other hand, is already in the AppStore and is much more stable and reliable than its Android counterpart.

Hope to see you all at the Pebble course!

Tuesday, February 18, 2014

Slides for my presentation on Bluetooth Low Energy and iBeacons programming in Riga, Latvia - 12 Feb 2014


I presented a session on Bluetooth Low Energy and iBeacons programming in Riga, Latvia on the 12 Feb 2014. If you did not make it for the event, here is the slide deck that I used for my presentation.


Tuesday, February 04, 2014

Article - Using Background Fetch in iOS

I am super excited to see my latest article published on MobiForge. Here is the abstract:

"In iOS, except for some special cases, an application is not allowed to run in the background. While certainly a serious restriction for some types of application, this feature is designed to conserve battery power. Imagine apps continuing to run in the background without reins, and it is easy to see how the entire system might slow down and deplete the battery within a few hours.

Apple takes a measured approach to background processing. In the early days of the iPhone, after complains from developers about the inability to run apps in the background, Apple introduced the Apple Push Notification service (APNS). APNs allows apps which are not already running to receive background push notifications, thereby allowing apps to be notified when some important events need their attention.

In iOS 7, Apple has introduced another feature to allow apps to run (more or less) in the background – Background Fetch. Background Fetch allows your app to continuously fetch data from the network when it is in the background. As an example, consider the Facebook app. When the Facebook app is in the background, it can continually fetch the latest news feed so that when the user switches the app to the foreground, the latest news feed is already ready for viewing.

In this article we'll take a look to see how background fetch can be used to connect to a Web service, the Open Weather Map API, so that your app can continue to update itself in the background."

Tuesday, January 21, 2014

Foundation of iPhone Programming course - 27-28 Jan 2014 - CONFIRMED

The Foundation of iPhone Programming course next week (27-28 Jan 2014) is confirmed! Learn how to write iPhone apps using Objective-C. You will also learn how to use Storyboard to build compelling UI for your iOS apps.


For quick registrations, email weimenglee@learn2develop.net and we will take care of the rest!


Sunday, January 19, 2014

iBooks Author and Keynote Courses


Interested to publish your own eBooks? In this 1-day course (MAC101), you will learn how to create your own iBooks using the new iBooks Author. You will learn how to quickly create interactive iBooks and preview them on your iPad. You will also learn how to publish your iBooks on the iBookstore.



Have an iOS device and want to create stunning presentation slides? In this 1-day course (MAC103), you will learn how to create your own award winning Keynote presentation slides, all from the comfort of your iPad!  You will learn how to quickly create compelling presentation slides and incorporate multimedia elements into your presentation.

Venue
Bayview Hotel Singapore
30 Bencoolen Street
Singapore 189621
9am to 5pm

Fees
MAC101 - S$399 (nett)
MAC103 - S$399 (nett)

Date
MAC101 - 14 Mar 2014 (Fri)
MAC103 - 7 Mar 2014 (Fri)



Download MAC101 course outline and application form here.
Download MAC103 course outline and application form here.

HRD101 - Getting Started with Raspberry Pi

I am pleased to announce that the next run of the Raspberry Pi course is on 28 Feb 2014.


Based on feedbacks from the previous runs of the course, we have put in more focus on hardware-related projects, such as:

    * How to build your own CCTV surveillance using a Webcam
    * How to build an iBeacon
    * How to detect motion
    * How to connect to a LCD display to display Twitter feeds

In addition, we will also cover how to set up your own Web server using Apache and PHP!

Venue
Bayview Hotel Singapore
30 Bencoolen Street 
Singapore 189621
9am to 5pm

Fee
S$599 (nett)

Date
28 Feb 2014 (Fri)



Download course outline and application form here.

Tuesday, January 14, 2014

Training Roadmap for iOS, Android, Wearable Computing, and Web Development

Confused with so many different courses? Not sure where to start from? We have compiled a series of training roadmaps for people who want to venture into the different areas. Have fun and feel free to share with your friends and colleagues!

Questions? Email us at weimenglee@learn2develop.net. 





Thursday, January 09, 2014

WEB102 – 1-Day Developing HTML5 Web Applications - NEW COURSE

HTML 5 is the new standard for the venerable HTML specification, a standard for displaying Web content. HTML has come a long way, going through a number of revisions - with the last version - 4.01, recommended by the W3C in 1999. The design goal of HTML 5 is to ensure that an application that you write can work on all browsers without the need to install additional plug-ins. It should be able to do everything from animation, to music and videos, local storage, offline applications, and more. HTML 5 is also cross platforms, meaning that your apps should be able to work whether it is run on a notebook, smartphone, tablet, or desktop computer.

In this 1-day course, you will be able to understand and use the new features of HTML5 through working with practical examples.

Topics

•          Quick Introduction to HTML
•          Crash Course in JavaScript and CSS
•          Using Canvas for drawing graphics    
•          Using SVG (Scalable Vector Graphics) in your HTML 5 pages
•          Implementing drag-and-drop in your Web Pages
•          Implementing LBS (Location-Based Services) in your Web applications
•          Embedding audios and videos in your Web pages
•          Using different input types in your Web pages
•          Using Web storage in HTML 5
•          Creating offline Web applications
•          Creating responsive Web applications using Web Worker

•          Implementing notifications in your Web applications through server messaging

Venue
Bayview Hotel Singapore
30 Bencoolen Street 
Singapore 189621

9am to 5pm

Fee
S$699 (nett)

Dates
21 Feb 2014 (Fri)

Download course outline and application form here.