發表文章

目前顯示的是有「Android」標籤的文章

[ AWS ] Android無法上傳檔案到S3 + AWS S3設定

因為我們公司有遇到新建立一個Bucket

[Android] Listview出錯

Don't call setOnClickListener for an AdapterView . You probably want setOnItemClickListener instead http://stackoverflow.com/questions/3402255/setonclicklistener-of-a-listview-not-working Because the Android API is designed that way if it's assigned to an adapterView, it will throw an exception. Clicking on a listView would mean a click on the entire view, which is usually not very useful anyway, since you mostly want to know in your app which exact child view item (list item) has been clicked, not that the entire listview has been clicked.  

Android專案更新

android升級到4.X之後我發現我舊的專案都不work 於是去google之後發現可以用android update project這個命令(command) 於是要先叫出command line並將目錄切換到android sdk 的tools/目錄下 之後在command line內輸入  android update project --name <要更新的專案名稱> --target <不知道target id就輸入android list targets就知道了> --path <要更新專案的所在路徑> 之後可能還會有點錯誤 但看eclipse的console得知對該專案點右鍵有個Android Tools 再來選Fix Project Properties就可以了! http://developer.android.com/guide/developing/projects/projects-cmdline.html#UpdatingAProject

Content Provider used in Service

其實用法跟在Activity內沒甚麼差別 因為兩個都是Context的subclass 都可以使用getContentResolver!

Android - window already focused

在寫Notification的時候一直跑出window already focused 當然Activity也就不能轉跳.. 結果原因是沒在Manifest.xml內把新寫的.java宣告在裡面! 寫下來警惕自己不要再犯這種蠢行為..

Android - 使用Content Provider

在用Content Provider時,通常會使用到一個class(使用者自訂)去extends  SQLiteOpenHelper 其中會需要override  public void onCreate(SQLiteDatabase db)   這個onCreate(SQLiteDatabase db)如果要被呼叫到 通常都是有使用到 SQLiteOpenHelper裡的getWritableDatabase() 程式會檢查有無db,沒有就會呼叫此onCreate( SQLiteDatabase db ) function! 例子 :  package com.android.GSensorActivity; import android.content.ContentProvider; import android.content.ContentValues; import android.content.Context; import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteQueryBuilder; import android.database.sqlite.SQLiteOpenHelper; import android.net.Uri; import android.util.Log; public class sensorProvider extends ContentProvider { public interface SensorSchema { String TABLE_NAME="SensorData"; String ORDER = "_order"; String DELTA = "delta"; String TIME = "time"; } private static class DatabaseHelper extends SQLiteOpenHelper { private ...