2012年12月27日 星期四

Local datetime in SQLite




This article shows how to get the local date time from SQLite


When we run the following SQL, it returns the UTC time..

select datetime('now');

2012-12-26 16:01:07




To return the local time, you can add the the parameter 'localtime' 

select datetime('now', 'localtime');

2012-12-27 00:01:07

2012年12月18日 星期二

[How-to] Get the year-month-day (yyyy-mm-dd) from a date field in SQLite

SQLite is the database for the Android Application.


The following SQL is an example of getting date by SQL statement.

select _id, strftime('%Y-%m-%d', create_date) c_date from TABLE1

Returned result:


Another SQL example shows how to get counts of records by date

select strftime('%Y-%m-%d', create_date), count(strftime('%Y-%m-%d', create_date) ) from TABLE1 group by strftime('%Y-%m-%d', create_date)



More reference for the date field in SQLite can be found in the official website
http://www.sqlite.org/lang_datefunc.html

2012年12月11日 星期二

[Resolved] Android: WebView Web Page not available

Today I'm trying to create a WebView in Android, it shows a Web page not available after running the app in the emulator.




       protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_main);
             
              WebView wv = (WebView) findViewById(R.id.webView1);             
              wv.loadUrl("https://www.google.com");
             
                }

Solution 

1. Make sure the permission is granted
<uses-permission android:name="android.permission.INTERNET"></uses-permission>


2. Make sure the following bold content in your code
       protected void onCreate(Bundle savedInstanceState) {
              super.onCreate(savedInstanceState);
              setContentView(R.layout.activity_main);
             
              WebView wv = (WebView) findViewById(R.id.webView1);
              wv.setWebViewClient(new WebViewClient(){});
             
              wv.loadUrl("https://www.google.com");
             
                }

2012年11月25日 星期日

Andriod Permission: Connect to Internet



The following permission should be grant for the internet connection from Android Application.

<manifest xmlns:android="http://schemas.android.com/apk/res/android" ... />
    ...
    <uses-permission android:name="android.permission.INTERNET" />
</manifest>

[RESOLVED] E/ERR(1183): org.apache.http.conn.HttpHostConnectException: Connection to http://localhost refused

Today I am trying to write an android program to retrieve an XML data from localhost server. When running the program, the following error occurs:

E/ERR(1183): org.apache.http.conn.HttpHostConnectException: Connection to http://localhost refused




              String url = "http://localhost:100/test.xml";

              try {
                     DefaultHttpClient httpClient = new DefaultHttpClient();
                     HttpPost httpPost = new HttpPost(url);

                     HttpResponse httpResponse = httpClient.execute(httpPost);
              } catch (ClientProtocolException e1) {
                     // TODO Auto-generated catch block
                     e1.printStackTrace();
              } catch (IOException e1) {
                     // TODO Auto-generated catch block
                     e1.printStackTrace();
              }
             
 


Solution:
The Android emulator could not recognize the localhost and results in connection refused.
To resolve, we can change the localhost to the ip address 10.0.2.2 and try again, problem resolved.

e.g. String url = "http://10.0.2.2:100/test.xml";
 



2012年11月15日 星期四

The project was not built due to "Could not delete '/XXXX'."

Sometimes when building the java application, the following error occurs:

The project was not built due to "Could not delete '/XXXX'.". Fix the problem, then try refreshing this project and building it since it may be inconsistent



Solution:
1. Click: Project --> Clean
 


2. After rebuild, the error is gone!

2012年11月11日 星期日

[RESOLVED] INSTALL_FAILED_MISSING_SHARED_LIBRARY when using Google API

Today I'm trying to write Google Maps Application on Android. When running the application, the following errors occur:



[2012-11-11 20:20:45 - XXX] Installation error: INSTALL_FAILED_MISSING_SHARED_LIBRARY
[2012-11-11 20:20:45 - XXX] Please check logcat output for more details.
[2012-11-11 20:20:45 - XXX] Launch canceled!


Resolution:
It is because Google Maps is not installed on the device / emulator.

1. Choose the Android Version and install "Google APIs by Google Inc."

2. In project properties, choose Google APIs as the Project Build Target.

3. Build again and success!


2012年11月4日 星期日

Unable to resolve target 'android-14'

When importing an old source code in eclipse today, the following error occurs:
Unable to resolve target 'android-14'


It is because android-14 does not installed in the machine.
You can change the android version via the project properties. For example, the API version for Android 4.0.3 is 15.


Then open the AndroidManifest.xml to change the sdk version to 15.
<uses-sdk android:minSdkVersion="15" />


2012年6月18日 星期一

[SOLVED] A Java Runtime Environment (JRE) or Java Development Toolkit (JDK) must be available in order to run Eclipse


A Java Runtime Environment (JRE) or Java Development Toolkit (JDK) must be available in order to run Eclipse. No Java virtual machine was found after searching the following


Solution:

Java must be installed in your Windows in order to run eclipse.
http://java.com/en/download/index.jsp

After installed Java, set the JAVA PATH in System Variable.

2012年2月17日 星期五

One Hand Operation in Galaxy Note (Firmware Version: N7000XXLA4)


  This article shows how to turn on the One Hand Operation in Samsung Galaxy Note. It is a new feature after the upgrading the Firmware 2.3.6. N7000XXLA4

The step by step procedure of the Firmware Upgrade can be found below.
http://yp-appdev.blogspot.com/2012/02/firmware-upgrade-on-galaxy-note-236.html











1. Go to Language and keyboard


2. Tick One hand operation

3. You may find the One hand operation in Calculator, Phone Dial Pad....

2012年2月12日 星期日

Firmware upgrade on Galaxy Note 2.3.6 N7000XXLA4

There is an offical upgrade on the Galaxy Note 2.3.6. It is a minor version upgrade.


Update / Improvement
By observation, there are many improvements on the phone (or new feature)
- faster!
- torch widget
- one hand operation (shift the button to one side) Click for detail
- improve the middle red problem in the camera
- touch screen sensitivity

2012年1月15日 星期日

Android Development for Beginner: Snake


This tutorial is for the beginner and demonstrate how to implement a tradition game "Snake" using Android 4.0.3.

The source code of this tutorial are extracted from the android developer official website and we will show you step by step on how to download and run the program. (http://yp-appdev.blogspot.com/)





2012年1月9日 星期一

[SOLVED]: Unable to find a 'userdata.img' file for ABI armeabi to copy into the AVD folder


System may returns error in creating an Android Virtual Device for the 4.0.x android ice cream sandwich and returns the error message in console
Unable to find a 'userdata.img' file for ABI armeabi to copy into the AVD folder.



Solution

Install ARM EABI v7a System Image and the problem is resolved! (http://yp-appdev.blogspot.com/)

After the installation, create the Android Virtual Device again and no errors found.


AVD Created


Success!




2012年1月2日 星期一

Using Eclipse to create an Android 4.0.x project

This tutorial shows how to create an Android 4.0.x project by using Eclipse, and create an Android

Before going thought this tutorial, you should install your eclipse as well as the android SDK in your machine, please take a look to my previous tutorial for the setup.
http://yp-appdev.blogspot.hk/2012/01/android-eclipse-development-platform.html
 
1. Create a new project by clicking File -> New -> Other


Android + Eclipse Development Platform Setup


The following tutorial shows how to setup the development environment for Android.

You have to install the following software in your machine.
- JAVA SDK
- Eclipse
- Android Development Kit

Steps by steps
1. Download and Install the latest version of the Java SDK.