Saturday, August 24, 2013

Sony Tablet S

Sony finally released update for Sony Tablet S?

It says for US but am looking forward for its arrival.

https://blog.sony.com/2013/04/jelly-bean-for-xperia-tablet/

Tuesday, August 20, 2013

User Identities in Thunderbird

Thunderbird have see lots of changes but the basic features for email have been retained. One of this, is being able to choose different ways to compose a message before it is sent out.

Example case 1; I have different signatures for friends, customers, special clients and for the general use. Switching signatures is so easy.

Example case 2; Some sent emails must be save to my SPECIAL folder.

Example case 3: Some emails must contain a CC or BCC to specific persons.

Example case 4: When I replay some quote of previous email is at the top and some at the bottom.

We can get this done is a few simple steps (I list the general steps here);

Step 1: In TB, click Tools ->Account settings...
Select the Email account and set the default email settings for

Your name:
Email Address:
Reply-to Address:
Organization:
Signature Text:

Step 2: Strongly suggest to create a text file and place the signature and name. 
Use the option for
Attach the signature from a file instead (text, HTML, or image)

Step 3: Configure following settings;
Copies and folders
Composition & Addressing
Security

Step 4: Click the Email account (selected in step 1)
Click button Manage Identities...
Click Add...

Enter the alternative email configuration. E.g. The alternative email signature.

Click OK, Close. You can continue to create as many identities as you like.
Click OK

DONE!
Try to send an email, click Write button.

Notice the "From" have a drop down list of all the different styles and configuration that you have created.

Wednesday, August 14, 2013

Using Handlerbars and JQuery in PhoneGap

Here is the very basic steps to use a template model in a PhoneGap application. I won't be going in details in this note.
"Those attending the PhoneGap class should incorporate the database as a practice. Thank you"

Ensure that the following steps have already been taken
  1. Creating Android App with PhoneGap
  2. Using Alert Pop-up
Step 1: Install the Handlebars and JQuery scripts
Download
  1. Handlerbars from http://handlebarsjs.com
  2. JQuery 1 from http://jquery.com/download/
Extract and copy the .js files to the Project's assets/www/lib folder

Step 2: Update the index.html
Replace the the contents within the body tags with the following;

 <h1>Hello PhoneGap</h1>  
  <script id="a-comment" type="text/x-handlebars-template">  
   <p><b>{{name}}</b> on {{date}}</p>  
   <ul>  
   {{#each comment}}  
   <li>{{description}}  
   {{/each}}  
   </ul>  
 </script>  
 <script src="lib/handlebars.js"></script>  
 <script src="lib/jquery-1.10.2.min.js"></script>  
 <script src="js/main.js"></script>  

Step 3: Update the js/main.js
Remove the initialize: function() and add following codes;


      renderHomeView: function() {  
      var today = new Date();  
      var dateTxt = today.getDate() +   
      "." + (today.getMonth()+1) +  
      "." + today.getFullYear();        
      var data = {  
      name: "I am the One",   
      date: dateTxt,  
      comment: [  
           { description: "walking with you."  
           },   
           { description: "eating together."  
           },  
           { description: "driving around town."  
           },  
      ] };  
   $('body').html(this.homeTemplate(data));       
   },  
   initialize: function() {  
        var self = this;  
        var source = $("#a-comment").html();  
     self.showAlert('This is how its done','Info');  
     this.homeTemplate = Handlebars.compile(source);  
     this.renderHomeView();  
   }  

Alert Pop-up in PhoneGap

Using the native notification or browser alert pop-up

This is a continuation from the Previous notes: Creating an Android App with PhoneGap and Eclipse
Purpose: Display the Alert pop-up before the application display its contents.

Step 1: Create the main.js
In the project's assets/www create js folder, then create a new text file and name it as main.js
Place the following contents in assets/www/js/main.js

 var app = {  
      showAlert: function (message, title) {  
    if (navigator.notification) {  
     navigator.notification.alert(message, null, title, 'OK');  
    } else {  
     alert(title ? (title + ": " + message) : message);  
    }  
      },  
   initialize: function() {  
        var self = this;  
     self.showAlert('This is how its done','Info');  
   }  
 };  
 app.initialize();  

Step 2: Load main.js from index.html
Edit index.html. Immediately after the body tag place the following 1 line.

 <script src="js/main.js"></script>  

Step 3: Test the application.
See previous posting on how to do this.

Creating an Android App with PhoneGap and Eclipse

This is the basics on creating a HelloWorld using PhoneGap, Cordova and Eclipse (provided by ADT).

I have downloaded and extracted:
  1. Android Development Toolkit (ADT): adt-bundle-windows-x86_64-20130729.zip
  2. Phonegap kit: phonegap-2.9.0.zip
Note: ADT provides the Eclipse IDE.

In order to start development, an Android project is created in Eclipse.

Step 1: Create an Android Project
Open Eclipse (Its in the ADT/eclipse folder) and choose File ->New ->Android Application Project

Application Name: Hello World (This is the name that will appear in the Play Store)
Project Name: HelloWorld (This is the name used by Eclipse to separate each project)
Package Name: com.example.HelloWorld

Select the default option for the remainder screens.

Step 2: Insert the Android/PhoneGap Libraries
In the project, left click on assets and create a new folder: www

Open the extracted PhoneGap/lib/android folder and do the following;

  1. Copy PhoneGap/lib/android/cordova.js to Project's assets/www folder
  2. Copy PhoneGap/lib/android/cordova-2.9.0.jar to Project's libs folder
  3. Copy PhoneGap/lib/android/xml folder to Project's res folder
In the Project's lib/cordova-2.9.0.jar right click and choose Build Path ->Add to Build Path

Step 3: Create the starting page
In assets/www folder, create the text file index.html with following contents
 <!DOCTYPE HTML>  
 <html>  
 <head>  
 <title>PhoneGap</title>  
  <script type="text/javascript" charset="utf-8" src="cordova.js">  
  </script>  
  </head>  
  <body>  
  <h1>Hello PhoneGap</h1>  
  </body>  
  </html>  

Step 4: Configure to load the index.html
Edit the Project's src/com.example.HelloWorld/MainActivity.java

Before the first import statement, add
import org.apache.cordova.*;

Change extends Activity 
to extends DroidGap
or to extends PhoneGap

Change setContentView(R.layout.activity_main);
to

super.loadUrl("file:///android_asset/www/index.html");

Step 5: Configure Android specific configurations
Edit the AndroidManifest.xml (if unsure where, just place it before the Activity Application tag)
 <uses-permission android:name="android.permission.READ_PHONE_STATE" />  
 <uses-permission android:name="android.permission.INTERNET" />  
 <uses-permission android:name="android.permission.READ_CONTACTS" />  
 <uses-permission android:name="android.permission.WRITE_CONTACTS" />  

Edit the Activity tag by adding configChanges
 <activity  
  android:name="com.tboxmy.simpledisplay.MainActivity"  
  android:label="@string/app_name"   
  android:configChanges="orientation|keyboardHidden|screenSize" >  

Step 6: Test the application
Right click the project name and choose Run As ->Android Application

Unless you have a fast machine with huge RAM, some waiting time is required for the Application to start, after the Android Emulator starts.

Friday, August 2, 2013

Cordova basic usage

Time to compile Phonegap using Cordova.
Basic commands;

1. Create an Android project called com.example.hello in folder hello.

cordova create hello com.example.hello 

2. Include Android platform for cordova. In the project folder, type;

cordova platform add android

3. Compile the project (some call this build). In the project folder, type;

cordova build

2. Start the android emulator with the compiled cordova project. In the project folder, type;

cordova emulate android

Thursday, August 1, 2013

Install Android Emulator on Centos 6


Why would I want to have the Android Emulator? Well, I needed to test several custom Android  Packages and also develop apps for Android. This meant, I could keep testing the Android Packages without having to install on a physical Android phone such as the Sony Ericsson X10 or Samsung S3.

I have written on this topic for Centos 64bits, before and seems like it still depends on 32bit libraries:


A good reference for everything Android is at http://developer.android.com/sdk/index.html

Here are steps for Centos 6.4 (64bits), open up a terminal as root;

Step 1: Install Java development kit (JDK)
# yum update
# yum install java-1.7.0-openjdk-devel.x86_64

Verify installation with following command:
# javac -version

Step 2a: Install library for 32bits 
yum install glibc.i686 ncurses-libs.i686 libstdc libstdc++.i686 libzip.i686 SDL.i686 gegl.i686  mesa-libGL.i686

Note: Optional package to install: 
libX11.i686 libXrandr.i686

Step 2: Install the Android SDK and ADT
Get the latest Android ADT from the Android Developer site or use following:
wget http://dl.google.com/android/adt/adt-bundle-linux-x86_64-20130729.zip

This will provide us with (Size if 440MB):
  1. Eclipse + ADT plugin
  2. Android SDK Tools
  3. Android Platform-tools
  4. The latest Android platform
  5. The latest Android system image for the emulator
Note: If you are in Malaysia and cant download because of Internet problem (Some day this will improve) and really have no other way of getting the ADT and JDK for Centos 6 64bits, just email me your contact details (e.g. address) and we can work something out.

Allow groups named devel to access development. Create the directory /opt/android and extract adt-bundle-linux-x86_64-20130729.zip

# mkdir /opt/android
# useradd -m devel
# chown devel.devel /opt/android
# chmod g+rwsx,+t /opt/android
# unzip -d /opt/android/ adt-bundle-linux-x86_64-20130729.zip

Step 3: Post installation.
What can we do after installation? Well, you can run the Eclipse IDE to develop application and there is also the Android Emulator (to test APK). Info on the Android Emulator can be found at http://developer.android.com/tools/devices/emulator.html

I suggest that you login as the devel user or a user with that group access to continue (Represented as $ in steps below).

Start Eclipse with
$ /opt/adt-bundle-linux-x86_64/eclipse/eclipse

Starting with the emulator
1. Listing the available emulators
$ cd /opt/android/adt-bundle-linux-x86_64/sdk/tools
$ ./android list targets

Available Android targets:
----------
id: 1 or "android-18"
     Name: Android 4.3
     Type: Platform
     API level: 18
     Revision: 1
     Skins: WSVGA, WVGA800 (default), WVGA854, WQVGA432, WQVGA400, WXGA800, QVGA, WXGA720, HVGA, WXGA800-7in
     ABIs : armeabi-v7a

2. Creating an instance of the emulator
Here it is called practiceandroid4.3 with the target id 1 (as above). Items in RED are optional. For further details see http://developer.android.com/tools/devices/managing-avds-cmdline.html
$ android create avd -n practiceandroid4.3 -t 1 --skin WVGA800
$ emulator -avd practiceandroid4.3


APK can be installed into the Android emulator
$ adb install bin/MyFirstApp-debug.apk


Trouble shooting:

  • If there is a problem running Eclipse or the Emulator, try the Step 2a above.
  • For error "./emulator: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory", ensure the step 2a is done.
  • When upgrade Centos 6.3 to Centos 6.4 on Virtualbox, it hangs at the boot progress bar. Fix is at http://bugs.centos.org/view.php?id=6306