2013年6月20日 星期四

鐵馬族的好幫手 --> 樂活鐵馬 v1.10 已於 google play 上架


樂活鐵馬 v1.10
提供:
即時定位
(提供時間/速度/距離/方位/精確度等訊息)
路徑紀錄
(背景運作將行經路徑資料寫進資料庫)
歷史紀錄查詢
(提供查詢時間所記錄的路徑騎乘資訊)
鄰近商家提示
(地址/聯絡方式/路徑規劃)
提供帳號登入功能
(可供多人使用同一套APP)


執行畫面:

版本歷程:
20130624
==> v1.10 發佈
(1)增加進入程式速度
(2)現在可以在背景運作了!!

20130621
--> v1.0 google play 上架

Google Maps 崁入式參數筆記

Google Maps嵌入參數
相關介紹
http://jax-work-archive.blogspot.tw/2011/07/google-maps.html
輸入範例
http://maps.google.com/maps?f=d&saddr=25.037525,121.56378199999995&daddr=25.063623,121.502297&hl=tw&dirflg=r



f=控制查詢表單的顯示風格。
f=d顯示成路徑規劃表單(有兩個輸入框,始點、終點)

Directions/路徑規劃
saddr= 出發點地址。
daddr=目標地址。 
“+to:” 可以使用+to:子句增加多地點線路規劃時的目標地址信息,比如daddr=大石洞村+to:馬欄廣場+to:棠梨溝
mra ?? 此參數涵義未知,可能的取值:dm/dpe/cc/ls…
mrcr ??此參數涵義未知,可能的取值:0
mrsp解析座標到街名。
mrsp=0打開從座標解析街名
mrsp=1關閉從座標解析街名
mrad= 附加目標地址。如果你的行程有三個地點,你可以用saddr=,daddr=和mrad=表示,而不採用+to:子句。
dirflg 路線類型。
dirflg=h避免高速公路。
dirflg=t避免收費路段。
dirflg=r採用公共交通。僅在一些區域可用。還可以提出附加的時間信息。
dirflg=w步行方式。仍在測試狀態。
dirflg=b騎行方式。僅在某些區域可用,仍在測試狀態。

Output Control/輸出控制
hl=主機語言。僅支持一部分語言,如hl=fr表示法語


Google Geocoding API
原廠介紹
https://developers.google.com/maps/documentation/geocoding/?hl=zh-tw

輸入範例
https://maps.googleapis.com/maps/api/directions/json?origin=25.037525,121.56378199999995&destination=25.047924,121.51708099999996&sensor=false
https://maps.googleapis.com/maps/api/directions/json?origin=25.037525,121.56378199999995&destination=25.063623,121.502297&sensor=false&mode=walking
https://maps.googleapis.com/maps/api/directions/json?origin=25.037525,121.56378199999995&destination=25.063623,121.502297&sensor=false&mode=bicycling
https://maps.googleapis.com/maps/api/directions/json?origin=25.037525,121.56378199999995&destination=25.063623,121.502297&sensor=false&mode=driving

搜尋附近地區的方式
https://maps.google.com/?q=加油站&near=龍華科技大學
上述方法無法查到所要的結果
near 後方要接的參數應為 地方名稱,實際地址 or 實際地址
範例
https://maps.google.com/?q=加油站&near=龍華科技大學,333台灣桃園縣龜山鄉萬壽路一段300號

或使用 near=25.024173,121.401817
範例:
https://maps.google.com/?q=加油站&near=25.024173,121.401817

2013年6月10日 星期一

取得自定 ListView 中的 Widget,如 TextView 的值

利用 findViewById 即可
程式碼:
以下為監聽 OnItemClickListener 事件
//==============================
@Override
public void onItemClick(AdapterView parent, View view, int position, long id) {
Log.i("==MainGo==", "進入 listView onItemClick 區段");
TextView tv = (TextView)view.findViewById(R.id.tv_list_type);
Log.i("==MainGo==", tv.getText().toString());
}




自定 listView 的 xml 檔:

    android:id="@+id/TableLayout1"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@drawable/tv_show_text_list" >

            android:id="@+id/tableRow1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >

                    android:id="@+id/tv_list_type"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/str_list_type"
            android:textAppearance="?android:attr/textAppearanceSmall"
             />
     
                    android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/str_list_go"
            android:textAppearance="?android:attr/textAppearanceSmall"
             />      

                    android:id="@+id/tv_list_name"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:text="@string/str_list_name"
            android:textAppearance="?android:attr/textAppearanceSmall"
             />


【參考網頁】http://stackoverflow.com/questions/15678281/get-spacial-content-of-selected-item-in-listview-in-android
   



2013年6月6日 星期四

如何使用 DialogFragment 做出自己的 DatePickerDialog 並將時間設定值設定在EditText元件中

自訂一個 class extends DialogFragment
public class MyDialogFragment extends DialogFragment implements OnDateSetListener{

@Override
public void onDateSet(DatePicker view, int year, int monthOfYear,
int dayOfMonth) {

String mYear = String.valueOf(year);
String mMonth = (monthOfYear+1 > 9)? (monthOfYear+1) +"" : "0" + (monthOfYear+1);
String mDay = (dayOfMonth > 9)? (dayOfMonth) +"" : "0" + (dayOfMonth);

EditText etday = (EditText)getActivity().findViewById(R.id.et_birthday);
etday.setText(mYear + mMonth + mDay);
}


@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

final Calendar c = Calendar.getInstance();
int Year = c.get(Calendar.YEAR);
int Month = c.get(Calendar.MONTH);
int Day = c.get(Calendar.DAY_OF_MONTH);
       
   return new DatePickerDialog(getActivity(), this, Year, Month, Day);
}
}

在要顯示Dialog 的 Activity 使用
MyDialogFragment myDateDialog = new MyDialogFragment();
myDateDialog.show(getFragmentManager(), "datePicker");

即可...

紅色部分為 layout 中的 EditText

2013年6月2日 星期日

Android eclipse logcat 錯誤排解清單

只要有遇到就會加進這篇

Unexpected value from nativeGetEnabledTags: 0
http://stackoverflow.com/questions/13416142/unexpected-value-from-nativegetenabledtags-0

“com.android.exchange.ExchangeService has leaked …” error when running emulator [closed]
http://stackoverflow.com/questions/14111677/com-android-exchange-exchangeservice-has-leaked-error-when-running-emulato
http://stackoverflow.com/questions/13765122/various-android-logcat-errors

Android LogCat device disconnected
: E/(): Device disconnected
http://stackoverflow.com/questions/15169115/android-logcat-device-disconnected

Android 移除狀態列、標題(全螢幕),螢幕固定方向,取得螢幕大小

Android 單一頁面移除狀態列、移除標題(全螢幕)

requestWindowFeature(Window.FEATURE_NO_TITLE);      getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);

全部頁面移除狀態列、移除標題(全螢幕)

AndroidManifest.xml中在起始的activity中加入
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"



限制應用程式只能直立,禁止橫向

setRequestedOrientation( ActivityInfo.SCREEN_ORIENTATION_PORTRAIT );
or AndroidManifest.xml:
android:screenOrientation="portrait" (指定為直向) 
android:configChanges="keyboard|keyboardHidden|orientation" (告訴系統,我要自己處理轉向問題) 
需要在 Manifest.xml 中加上底下的敘述。

設定螢幕強迫旋轉 固定在哪一個方向

int nOrientation = getRequestedOrientation(); 
if (nOrientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) 
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); 
else 
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); 
需要在 Manifest.xml 中加上底下的敘述。
【參考範例】
http://androidbiancheng.blogspot.tw/2011/07/setrequestedorientation.html
http://androidbiancheng.blogspot.tw/2010/10/java-setrequestedorientation.html

解決倒退鍵無法直接退出應用程式問題

    @Override
    protected void onDestroy() {
     super.onDestroy();
     android.os.Process.killProcess(android.os.Process.myPid()); 
    }

取得螢幕大小

DisplayMetrics metrics = new DisplayMetrics();   
        getWindowManager().getDefaultDisplay().getMetrics(metrics);
TextView TextView1 = (TextView)findViewById(R.id.TextView01);

        TextView1.setText("手機螢幕大小為 "+metrics.widthPixels+" X "+metrics.heightPixels);

Related Posts Plugin for WordPress, Blogger...