Browsed by
Category: Android

[Android] HttpsURLConnection.getResponseCode = -1

[Android] HttpsURLConnection.getResponseCode = -1

Recently I used below code to implement my app to connect server using HttpsURLConnection, I can connect to the web service with inputted username and password, and get a response back, however I found sometimes the android 2.2 device will throw “org.xml.sax.SAXParseException: Unexpected end of document” error message in logcat.

Read More Read More

Facebooktwittergoogle_plusredditpinterestlinkedinmail
[Android] Google Calendar API change for ICS

[Android] Google Calendar API change for ICS

Recently I try to create an app which stored event in device calendar, I found this app will crash in Ice Cream Sandwich device. But the same codes in Ginger Bread device will work well. I checked the logcat, and found below logs:

java.lang.IllegalArgumentException: Event values must include an eventTimezone
at com.android.providers.calendar.CalendarProvider2.validateEventData(CalendarProvider2.java:2486)
at com.android.providers.calendar.CalendarProvider2.insertInTransaction(CalendarProvider2.java:2064)
at com.android.providers.calendar.SQLiteContentProvider.insert(SQLiteContentProvider.java:96)
at android.content.ContentProvider$Transport.insert(ContentProvider.java:189)
at android.content.ContentProviderNative.onTransact(ContentProviderNative.java:152)
at android.os.Binder.execTransact(Binder.java:338)
at dalvik.system.NativeStart.run(Native Method)

Read More Read More

Facebooktwittergoogle_plusredditpinterestlinkedinmail
[Android] Catch the Home key control

[Android] Catch the Home key control

Android中的Home鍵,在Android的機制中,為了避免惡意軟體讓使用者無法終止軟體而回到桌面,所以在使用onKeyDown方法時,無法捕獲按下Home key的行為。

而在一般的軟體中,按下Home key時,雖然回到桌面,但並不會結束軟體,這次開發的軟體中,需要按下Home鍵時立即結束軟體,但在無法捕獲Home key的狀況下到底該如何做呢?

Read More Read More

Facebooktwittergoogle_plusredditpinterestlinkedinmail
[Android] android.view.ViewRoot$CalledFromWrongThreadException

[Android] android.view.ViewRoot$CalledFromWrongThreadException

今日寫軟體中的某個畫面,我使用了new thread來加速圖片的處理以及使用Progressbar,原本以為應該很快就可以寫好的程式,在測試時卻一直跳出exception:android.view.ViewRoot$CalledFromWrongThreadException: Only the original thread that created a view hierarchy can touch its views.

問了孤狗大神才知道原來不能在major thread以外的thread更新使用者介面,所以需先在thread中,download圖片至手機中,download完畢時,sendMessage to Handler,接著在把剛剛download下來的圖片設定至bitmap中,並更新使用者介面才能完成整個流程。

Read More Read More

Facebooktwittergoogle_plusredditpinterestlinkedinmail
[Android] Failed to parse the output of ‘adb version’

[Android] Failed to parse the output of ‘adb version’

昨天心血來潮安裝了最新版本的Eclipse V3.7 Indigo以及最新的Android developer tool R12,接下來就是惡夢的開始…..

一開始將Android專案import之後,每個專案皆出現令工程師恐懼的紅色叉叉,且console一直出現:Android requires compiler compliance level 5.0 or 6.0. Found ‘1.4’ instead. Please use Android Tools > Fix Project Properties

Read More Read More

Facebooktwittergoogle_plusredditpinterestlinkedinmail