Showing posts with label Android Training Course. Show all posts
Showing posts with label Android Training Course. Show all posts

Friday, May 03, 2013

Android Tip - Displaying a PDF Document inside a WebView


One of the most requested features in Android is the ability to display a PDF document within a WebView. However, the WebView does not contain a PDF plugin that allow you to display a PDF document. One solution is to use an Intent object to launch a third-party app (such as Adobe Acrobat) which can handle the PDF document. However, this will transfer control over to the thrid-party app.

If you insists on displaying the PDF document within your own activity using a WebView, you can use the following trick. You can use Google Docs to open your PDF document and then load the URL of Google Docs using the WebView.

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //setContentView(R.layout.activity_main);
        WebView webView=new WebView(MainActivity.this);
        webView.getSettings().setJavaScriptEnabled(true);
        webView.getSettings().setPluginState(PluginState.ON);

        //---you need this to prevent the webview from
        // launching another browser when a url
        // redirection occurs---
        webView.setWebViewClient(new Callback());
       
        String pdfURL = "http://dl.dropboxusercontent.com/u/37098169/Course%20Brochures/AND101.pdf";
        webView.loadUrl(
"http://docs.google.com/gview?embedded=true&url=" + pdfURL);

        setContentView(webView);
    }

    private class Callback extends WebViewClient {
        @Override
        public boolean shouldOverrideUrlLoading(
                WebView view, String url) {
            return(false);
        }
    }

The loaded PDF document will look something like this:



Remember to add in the android.permission.INTERNET permission.

Come join me in the Android Post-Conference workshop on 31 May 2013 at DevTeach 2013, Toronto. 

Tuesday, April 30, 2013

Android Tip - Monitor a Location


Your application wants to monitor a particular location and when the device is near that location, you want to perform some actions. This is very useful if you are writing an application that reminds you when you are near to some places of interests.
 
One very cool feature of the LocationManager class is its ability to monitor a specific location. This is achieved using the addProximityAlert() method.

The following code snippet shows how to monitor a particular location so that if the user is within a five-meter radius of that location, your application will fire a PendingIntent object to launch the web browser:

import android.app.Activity;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.location.LocationManager;
import android.net.Uri;
import android.os.Bundle;

public class MainActivity extends Activity {
    LocationManager lm;
    PendingIntent pendingIntent;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        //---use the LocationManager class to obtain
        // locations data---
        lm = (LocationManager)
            getSystemService(Context.LOCATION_SERVICE);
    }

    @Override
    public void onResume() {
        super.onResume();
   
        //---PendingIntent to launch activity if the user
        // is within the proximity of some locations---
        pendingIntent = PendingIntent.getActivity(
            this, 0, new
            Intent(android.content.Intent.ACTION_VIEW,
                   Uri.parse("http://www.amazon.com")), 0);

        lm.addProximityAlert(37.422006, -122.084095,
                             5, -1, pendingIntent);
    }   

    @Override
    public void onDestroy() {
        super.onDestroy();
       
        lm.removeProximityAlert(pendingIntent);   
    }
   
}

The addProximityAlert() method takes five arguments: latitude, longitude, radius (in meters), expiration (time for the proximity alert to be valid, after which it will be deleted; -1 for no expiration), and the PendingIntent object.

Note that if the Android device’s screen goes to sleep, the proximity is also checked once every four minutes in order to preserve the battery life of the device. Also, your app would need the
android.permission.ACCESS_FINE_LOCATION permission.

Come Join Our Android Courses to Learn More!

17-18 June 2013

24-25 June 2013

26 June 2013

Saturday, April 20, 2013

Android Tip - Waking up screen and unlocking the device

In Android, there are times where you need to programmatically unlock the device and wake up the screen. For example, you might have a broadcast receiver that receives some broadcasts in the background. When a broadcast is received, you want to wake up the screen (which is likely to be off as the device goes to sleep) and display a notification to the user. In addition, if your device is locked, you would also need to programmatically unlock it. The following code snippet will unlock your device and wake up the screen:


import android.view.Window;
import android.view.WindowManager.LayoutParams;

...

        Window window = this.getWindow();
        window.addFlags(LayoutParams.FLAG_DISMISS_KEYGUARD);
        window.addFlags(LayoutParams.FLAG_SHOW_WHEN_LOCKED);
        window.addFlags(LayoutParams.FLAG_TURN_SCREEN_ON);

Give it a try and have fun!

Wednesday, April 03, 2013

Android Tip - Updating Your UI Safely on a Separate Thread

Very often, in your Android applications, you have several threads running in the background. And sometimes you need to update your UI (or perhaps display a Toast) from a background thread. In this case, you need to take special care to ensure that the update is done in a thread-safe manner. If not, your application will simply crash.

To update your UI in a thread-safe fashion, use the runOnUiThread() method:

runOnUiThread(new Runnable() {
    @Override
    public void run() {
        Toast.makeText(getApplicationContext(),
            "Some message to display", Toast.LENGTH_LONG).show();
    }
});

Thursday, March 01, 2012

Android Bootcamp at MobileTeach, June 1 2012, Vancouver, Canada


I am very excited to announce that I will be running an Android Bootcamp in MobileTeach, Vancouver, Canada (Post-Con Workshop, Friday June 1, 2012). In this bootcamp, I will get you up to speed with Android development within one day. If you always wanted to write your own Android apps but are too busy to read a book, this is the best chance for you to get started! At the end of the day, you will be able to write your own apps and deploy them onto your phone. I will show you how to write some really cool apps!

You can now get a rebate of $100 using this code MOBILETEACH02. See you at the bootcamp!



Monday, October 17, 2011

My book - Beginning Android Application Development adopted as textbook at Rock Valley College in Rockford, Illinois

I am very honoured to learn that my book - Beginning Android Application Development (WROX), has been adopted as a textbook at Rock Valley College in Rockford, Illinois, for their Android Programming class.

I am also super excited to learn that the staff and students are so far enjoying the book! Thanks for the support!


Monday, October 03, 2011

Come and learn the new features of iOS 5 and Android in Vancouver this December!

I will be running a series of iOS and Android courses this December in Vancouver at MobileTeach.

MobileTeach is a spinoff of DevTeach and we are proud to announce a series of workshop (12-17 Dec 2011) on the iOS and the Android this fall. The Event is divided in 3 classes: 2-days Foundation of iPhone Programming, 2-days Advanced iOS Programming and 2-days Android Programming. You can register for each event separately or for all events for a special price.

If you want a jumpstart to iOS and Android development, this is an event that you cannot afford to miss. Register today to enjoy the early bird discount!

Monday, September 12, 2011

iOS and Android Courses in Atlanta, Dec 2011

Here is my upcoming schedule at Atlanta in Dec 2011:

Upcoming Classes

Foundations of iPhone ProgrammingDec 5-6, 2011Atlanta, GA
Language: EnglishMore Info
separator
Advanced iOS ProgrammingDec 7-8, 2011Atlanta, GA
Language: EnglishMore Info
separator
Android ProgrammingDec 9-10, 2011Atlanta, GA
Language: EnglishMore Info
separator

Friday, September 02, 2011

Using your Borders Gift Card (Singapore) to offset against my courses

Recently, it was reported in the Singapore papers that due to the closure of Borders at Wheelock place, customers could no longer use its previously issued gift cards to make purchases at other branches. While this is a very disappointing news to a lot of customers, I have decided to follow the spirit of German Airline Lufthansa, who has very generously offered to let customers offset their air tickets value using their existing gift card.

As a book lover myself, I visit book stores regularly, especially Borders. I had been going there since I was a student, and had many fond memories. The smell and feel of books, and the aroma of coffee that fills the store has become a part of many peoples' lives.

Hence, I would like to offer existing Borders gift card holders to offset the fees for my courses using their existing Borders gift card. Every customer can offset a maximum of S$50 for any courses that they sign up. At this moment, here are the courses scheduled to run in Sep and Oct 2011:

September 2011
* 12 Sep 2011 - Objective-C Programming - S$499
* 13-14 Sep 2011 - Foundation of iPhone Programming - S$997
* 15-16 Sep 2011 - Advanced iOS Programming - S$997
* 19-20 Sep 2011 - Android Programming - S$997

October 2011
* 3 Oct 2011 - Objective-C Programming - S$499
* 4-5 Oct 2011 - Foundation of iPhone Programming - S$997

Details
* All courses will be held at Mountbatten Square, Singapore.
* Attendees have to bring their own notebook computers
* Training time: 9am to 5pm.

For enquiries, please call (65) 9-692-4065.

Wednesday, August 24, 2011

Android Programming - 19-20 Sep 2011

Come and join us in the upcoming Android Programming course on 19-20 Sep 2011. In this 2-day course, you will learn how to get jumpstarted with Android programming using Eclipse and the Android SDK in the shortest amount of time. This is a lab-intensive course that will have you up and running in just one morning! By the end of the day, you will be able to write your own Android apps and be like these guys.

Register today and every participant get a copy of my Beginning Android Application Development book!

Sample Project by Android Course Participant - Converts between degrees of Latitude and Longitude and MGRS

In last week's Android class at Fort Gordon, I have an outstanding participant - Chiam Krause, who took some jar files from the World Wind JAVA SDK and put together a coordinate converter that converts between degrees of Latitude and Longitude and MGRS. He has kindly shared the source code of his project on bitbucket. The project name is GridSquare.

Check out his blog here. Thanks, Chiam!

Saturday, August 20, 2011

Another Android app published by my course participants - Android Programming - US Aug 2011

Here is another app published by one of my Android Programming course participants (US Aug 2011).

Need help with figuring out fiber optic color code?
This is the app for you.

- Features
* Show colors and # from fiber optic pair count.
* Show pair colors, binder colors, and 600 binder color from a pair count using 25 pair color code.

Thursday, August 18, 2011

Android apps in the Android Market from participants of my Android class in the US - Aug 2011

This week I am in the US conducting my Android Programming class. And I am very proud to list the apps that some of my course participants have created in the short time span of a couple of days. Check out these apps in the Android Market. More will be listed as soon as they are available on the Android Market. This is way cool, guys!

Simple Tip Calculator that lets you choose the level of service that you had and it tells you how much of a tip you should leave based on the dollar amount of your ticket.









Protect Lives and Property within the Cove Acres calling area. Assist other Fire Districts as needed and requested.










A simple currency converter application to give you real-time currency exchange information for 80+ international currencies.

Internet/data connection is needed in order to obtain real-time rate.