2015年3月24日 星期二

Mysql 用法


A.Windows 的mysql command
1.從 Xampp的bin/mysql 匯入資料庫:
  mysql -u root -p joomla <  demo.sql










B.將original的columna欄位由 '.'字元分割 再存到 test1:
INSERT INTO test1 (account , mac , date , sys , dia)

SELECT account, mac , date,
SUBSTRING_INDEX(columna, '.', 1),
SUBSTRING_INDEX(columna, '.', -1) FROM `original`



C.字串取代:REPLACE(`欄位名稱`, '欲取代的字串', '取代後的字串')

# 將efg開頭的字串取代
UPDATE `table` SET `column` = REPLACE(`column`, 'efg', 'zzz') WHERE `column` LIKE 'efg%';
 
將efg結尾的字串取代
UPDATE `table` SET `column` = REPLACE(`column`, 'efg', 'zzz') WHERE `column` LIKE '%efg';
 
將欄位column_2含有efg字串取代成zzz,不過將取代後的結果覆寫於column_1,不更動column_2原有的內容
UPDATE `table` SET `column_1` = REPLACE(`column_2`, 'efg', 'zzz') WHERE `column_2` LIKE '%efg%';

2015年3月23日 星期一

Android 問題排除

A.Conversion to Dalvik format failed with error 1

     Eclipse -> Project -> Property -> Java Build Path 移除重複的jar檔案


B.Wechat Sample source code 執行問題:

source code下載:
 https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1419319167&lang=zh_CN
  1.加入本身的debug.keystore
 

2.重新安裝 Wechat Sample 的app


C. 錯誤訊息 - java.lang.VerifyError

     
     不可以將*.jar檔案放在bin資料夾裡 ,而是放在libs資料夾中
      

D.讓Support 7 的 mediarouter, appcompat 兩個 project正常輸入到Eclipse


1.將C:\Program Files (x86)\Android\android-sdk\extras\android\support\v7\appcompat
   以android exist project 輸入到Eclipse, 再設定android 5.0.1   
2.設定properties檔案等級對應21(系統可能自轉換過去)

3.為第二個mediarouter project設入 appcompat project作為依賴library


E.unsupport version 52 

1.重新下載android版eclipse 

2.以administrator 身分 , 開啟SDK Manager 將相關的API 18 安裝,也需注意 對應版本的 Android
Build Tools也安裝

3.進入Eclipse的Window-Preference-Java-Compiler-Compiler compliance level 設成 1.7

問題分析: 最新的Android SDK無法支援到Java 1.8 導致錯誤

2015年3月20日 星期五

Android Layout 編排

1.type 1:


<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context="${relativePackage}.${activityClass}" >

    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical" >

        <EditText
            android:id="@+id/edittext"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="message 1" />

        <Button
            android:id="@+id/send"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_margin="10dp"
            android:text="發送" />
     
    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        android:orientation="horizontal"
         >

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:autoLink="web"
                android:text="發送朋友圈"
                android:textSize="20sp" />

            <CheckBox
                android:id="@+id/check1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="ok"
               >
            </CheckBox>
      </LinearLayout>
    </LinearLayout>

</RelativeLayout>


2.將物件設置到中心位置:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:paddingTop="10dp"
    android:paddingBottom="10dp"
    android:orientation="horizontal"
    android:paddingLeft="16dp"
    android:paddingRight="16dp" >

    <!-- Title Of Song -->
    <TextView
        android:id="@+id/title"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center"
        android:textColor="#040404"
        android:textSize="18sp"
        android:textStyle="bold"
        android:typeface="sans" >
    </TextView>

   <TextView
        android:id="@+id/titlea"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_below="@id/title"   
        android:gravity="center"
        android:textColor="#a18787"
        android:textSize="15sp"
        android:textStyle="bold"
        android:typeface="sans" >
    </TextView>
</RelativeLayout>


3.全螢幕分割兩區之Layout:(最外層一定要為LinearLayout)

 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal"
    tools:context="${relativePackage}.${activityClass}" >

    <RelativeLayout
        android:layout_width="0dp"
        android:layout_weight="0.5"
        android:layout_height="match_parent"
        android:layout_marginBottom="20dp"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:layout_marginTop="20dp"
        android:background="@drawable/my_custom_background" >
     
        <Button
          android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="CLick"
            >
            </Button>
    </RelativeLayout>

    <RelativeLayout
        android:layout_width="0dp"
        android:layout_weight="0.5"
        android:layout_height="match_parent"
        android:layout_marginBottom="20dp"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"
        android:layout_marginTop="20dp"
        android:background="@drawable/my_custom_background" >
    </RelativeLayout>

</LinearLayout>


2015年3月15日 星期日

Wechat 開發

A.http://stackoverflow.com/questions/14565479/getting-started-with-the-wechat-android-sdk



B.申請可以發訊息的app_id:


資料來源-微信 開放平台->資源中心->資源下載->android資源下載
(https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&lang=zh_CN&token=1a0a48ed7ac2fa05954d120587ae576ec4e78195)

1.先放入wechat sdk sample(https://res.wx.qq.com/open/zh_CN/htmledition/res/dev/download/sdk/WeChatSDK_sample_Android221cbf.zip)於eclipse

2.生成keystore   , F:\keystore>keytool -genkey -v -keystore debug.keystore -alias androiddebugkey -keyalg RSA -keysize 2048 -validity 10000   (alias必為androiddebugkey  ,密碼為android)

3. 從eclipse  選取前一步產生的debug.keystore   (windows->preference->android->build->custom debug keystore)

4. eclipse 的 wechat sdk sample 安裝於手機

5.使用          apk_signature.apk
(https://res.wx.qq.com/open/zh_CN/htmledition/res/dev/download/sdk/Gen_Signature_Android221cbf.apk) 輸入 package name(androidmanifest.xml中可修改) ,得到 md5 碼
(使用大陸手機號碼)

6.申請app_id,  微信  開放平台  -> 創建移動應用 ->填入 md5碼與 package name ,等待審核
7.獲取app_id ,寫入sample code中,將之前的sample.apk移除,帶入新app_id重新安裝sample.apk,發送訊息



2015年3月9日 星期一

2015年3月6日 星期五

Git指令使用

使用putty 程式進去--

刪除git 的tag 分支專案:

  git tag -d <tag-name>



刪除 最後的commit紀錄:


(需要 先將 git clone下來, ex: git clone ssh://name@10.8.70.133/data/git/<project> -b  <branch1>)

進入project folder之後:

輸入指令:git reset --hard HEAD~1   (最前面的commit刪掉)
         git push -f

刪除 最後的commit紀錄(方法2)
進入project folder之後:
輸入指令:
                  git reset --soft HEAD~1


提交source code失敗之後的處理:


在Eclipse中
A.project右鍵  -> team -> pull (抓出新code)
B.project右鍵  -> team -> synchronize workspace (處理 衝突 的code)

  處理完衝突的code之後,按push 強制提交code                


   


處理Eclipse Git 因permission denied無法上傳檔案的問題

 到達work tree資料夾
sudo chown -R youruser .   (須加逗號)