2015年7月26日 星期日

【Eclipse] 中文出現亂碼 gibberish in chinese character

有時候import project的時候,就會出現中文亂碼#%$#%一整個很困擾
Sometime i import a project the chinese character all become %$#$%# !!!!
IT'S VERY NOISY!!!!! 

 SOLVE METHOD
 Step 1. 「Window」->「Preferences」
 Step 2. 「General」->「Workspace」。
 Step 3. 「Text file encoding」 Change Default (MS950) ->「UTF-8」。
 Step 4. Press 「Apply」

[Android] 通知(Notification)

Take a note !! so next time if i use notification it will become faster :")) 
新(New):Notification.Builder來快速產生出來
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE );
Builder builder = new Notification.Builder(Update.this );
PendingIntent contentIndent = PendingIntent.getActivity(Update. this, 0, new Intent(Update.this , Update. class),PendingIntent. FLAG_UPDATE_CURRENT);
builder.setContentIntent(contentIndent)
       .setSmallIcon(R.drawable.icon) // 設置狀態列裡面的圖示          
       .setTicker("New Message") // 設置狀態列的顯示的資訊
       .setWhen(System. currentTimeMillis()) // 設置發生時間
       .setContentTitle( "I-Calories計算結果通知" )//設置通知清單裡的標題
       .setContentText("共消耗"+ca); // 設置內容
							  
Notification notification = builder.getNotification();
notificationManager.notify(1, notification);
設定預設提示音(notification.defaults to set default alarm ring)
notification.defaults |= Notification.DEFAULT_SOUND;//預設鈴聲
相關連結(good learning website) 更詳細可以點及這個很棒的網站作更深入的學習 http://magiclen.org/android-notifications/ 
http://www.codedata.com.tw/mobile/android-tutorial-the-5th-class-2-notificationhttp://givemepass.blogspot.tw/2011/11/notification.html 
http://blog.maxkit.com.tw/2014/03/android-notification.html

[Android] Vibrate 振動實作

Sometime we need to let the phone vibrate when receive a message or something happen
我們現在來進行實做 "振動" 這項功能
  Vibrator myVibrator = (Vibrator) getApplication().getSystemService(Service.VIBRATOR_SERVICE);
  myVibrator.vibrate(1000);//millisecond

Don't forget to add in your AndroidManifest.xml!!!!!
<uses-permission android:name="android.permission.VIBRATE" />

[Android] Toast

We have two method to use Toast 我們有兩種方式來顯示Toast

1.ToastActivity.this depends on this class name
 Toast toast = Toast.makeText(ToastActivity.this,"Hello world!", Toast.LENGTH_LONG);
 toast.show();
2.getApplicationContext()to get Current Context
 Context context1 = getApplication();
 Toast.makeText(context2, "Hello world!", Toast.LENGTH_LONG).show();

2015年6月8日 星期一

Android-finished with non-zero exit value 1

I encounted a problem in android studio. it shows ".....finished with non-zero exit value 1"
all my R.~~has a red underline!!! 
i was really shock!!!

Solution:
I cleaned the project and solved

Reason:
I faced this issue after replacing png drawables with jpg with the same name

2015年5月31日 星期日

Google Glass - 'Jump' to a card in CardScrollView via setSelection doesnt work

I had found why it can't jump to specific card for 1~2days.
Finally i got a resolution. hope i could help others
This block is get the position and use animate to jump to the specific
 mCardScroller.setSelection(mCardScroller.getSelectedItemPosition() + 1);
 mCardScroller.startAnimation(AnimationUtils.makeInAnimation(mCardScroller.getContext(), true));
BUT!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! NOT WORK
IMPORTANT!!ADD THIS IN YOUR ONCREATE()
mCardScroller.activate()
AND CHECK THIS TWO LIFE PERIOD
@Override
    protected void onResume() {
        super.onResume();
        mCardScroller.activate();
    }

    @Override
    protected void onPause() {
        mCardScroller.deactivate();
        super.onPause();
    }
GOOGLE GLASS 跳到特定的CARD,如果你咬遇到一樣的問題setSelection始終無法使用,在ONCREATE()理面加入mCardScroller.activate()就會有結果了 希望可以幫住到更多人,因為GLASS的資訊好少,我們也花了一點時間來解決這個問題!!

2015年5月29日 星期五

[mySQL]hinet.net is not allow to connect to this mySQL server

When i tried to connect mySql (not localhost),i met a problem






[Solution]:Because other the authority
shell>mysql --user=root -p
輸入密碼
mysql>use mysql
mysql>GRANT SELECT,INSERT,UPDATE,DELETE ON [db_name].* TO [username]@[ipadd] identified by '[password]';

[username]:遠程登入的使用者代碼(userid)
〔db_name]:表示欲開放給使用者的數據庫稱(show for user db name)
[password]:遠程登入的使用者密碼(user pwd)
[ipadd]:IP地址或者IP反查後的DNS Name,此例的內容需填入'59-126-182-81.HINET-IP.hinet.net',包涵上引號(')

(其實就是在遠端服務器上執行,地址填寫本地主機的ip地址。)