2018年10月2日

已解除安裝,仍出現"安裝套件所使用的簽名和現有套件的簽名相同"

用adb uninstall com.xxx.xxx 即可!

2018年9月28日

Android: webview 呼叫JavaScript函數

本來執行得好好的程式碼,在新版的Android就失效了?
Debug了半天,原來是WebView不能在同一個Thread呼叫?

myWebView.loadUrl("javascript:alert('test')");

需要改成底下:

myWebView.post(new Runnable() {
@Override
public void run() {
myWebView.loadUrl("javascript:alert('test')");
}
});

2018年5月17日

Wired for memory: how your brain remembers by completing patterns

Wired for memory: how your brain remembers by completing patterns:

Your brain is the best pattern completion machine in the known universe.
We know the 海馬迴 is important for some types of this pattern completion. It deals with episodic memory, the memory of stuff that happened to you
CAT3區神經元間的連結很稀疏,有特定的chain模式,形成迴圈loop,才足以激發pattern completion.




2018年4月25日

Android: 在不同thread上,更改button上的文字

button1.post(new Runnable() {
                          public void run() {
    button1.setText(R.string.btn1);
                       } });

2017年8月30日

Service Intent must be explicit: Intent { act=com.android.vending.billing.InAppBillingService.BIND }

IabHelper.java

增加一行指令即可!

   public void startSetup(final OnIabSetupFinishedListener listener) {
        // If already set up, can't do it again.
        if (mSetupDone) throw new IllegalStateException("IAB helper is already set up.");
        // Connection to IAB service
        logDebug("Starting in-app billing setup.");
        mServiceConn = new ServiceConnection() {

              .....................省略

        };
       
        Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND");
        serviceIntent.setPackage("com.android.vending");

              .....................省略

    }

2017年7月28日

Android: In-app-billing 付費機制Google範例

Preparing Your In-app Billing Application
Administering In-app Billing
Security and Design

AndroidManifest.xml中必須增加底下宣告:
 <uses-permission android:name="com.android.vending.BILLING" />
Package的名稱必須Rename,
package com.wsj.android.trivialdrivesample;
換入你上傳App後的金鑰,
String base64EncodedPublicKey = "MIIBIjANBgkqhkiG9w0B...省略.....";
Google Play Console中,產生程式中購買的對應物品,以便測試

  • 手機的primary gmail帳號要設成測試gmail帳號,不能用開發者的gmail帳號!
  • APK必須發佈Alpha或Beta才能測試,利用所附的URL成為測試人員,然後下載APP.
  • "錯誤!此項目目前無法購買"<----退出計畫,後重新成為測試人員!!
  • 所欲購買項目必須啟動(in Active)
  • "錯誤!請先入登入GOOGLE帳戶"<---加入Alpha/Beta測試計畫
  • 測試帳號須登登錄信用卡資訊才能完成測試購買

2017年4月27日

Android: Eclipse 使用android-support-v7-appcompat.jar和android-design-support.jar和google-play-services

有些舊project不想翻新到Android Studio,但又想增加新功能,但是程式範例用到新的jar,不得已只好想辦法,舊瓶裝新酒。

android-support-v7-appcompat.jar :import程式碼project,編譯(target到android 5.0以上)。
引用的project在project的內容中,加入reference即可。

android-design.support.jar:引用的project直接用外部jar即可。

google-play-services:import /extras/google/google_play_services/libproject/google-play-services_lib專案。(好像r30版本之後沒有此專案!幸好還找得到下載舊版的地方)

2017年4月12日

Android: AlertDialog 改變其高度

AlertDialog alert = new AlertDialog.Builder(this).create();
alert.show();  
//
DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(metrics);
int h90 = (int)(0.9f*((float)metrics.heightPixels)) ;   //高度設為90%
alert.getWindow().setLayout(ViewGroup.LayoutParams.WRAP_CONTENT, h90);
//

2017年3月21日

Unable to execute dex: GC overhead limit exceeded in Eclipse

Export專案時,發生上述的錯誤,原來是Eclipse的在Eclipse.ini中的Xms和Xmx值設定太小,將其設成 512 和 1024 即可。
-Xms512m 
-Xmx1024m

2016年12月9日

Arduino: MIDI

Capacitive Sensing Library
Arduino Tutorial: Capacitive Touch Sensors
Pitch follower using the tone() function
Lab: MIDI Output using an Arduino
How to Make a Cheap Arduino MIDI Controller


2016年5月7日

備份 git project 到檔案

  1. 切換到 project 所在目錄 
  2. 備份指令 GitBash$ git bundle create 檔名 --all 
  3. 重建指令 GitBash$ git clone 檔名  新目錄

2016年3月16日

Win10 安裝 vs2010 未正確載入套件 'xxxxxxx'

好不容易裝完Visual studio 2010 又裝完Sp1,正高興的時候,載入專案居然不行!!天呀,這是什麼情形......心中暗自捶心肝

未正確載入套件 'Microsoft.VisualStudio.Editor.Implementation.EditorPackage'

心想會不會是安裝過程有誤,重新安裝,當然還是不行 :-(
還好google到一篇文章,有類似的情形發生,解決的方法是去刪除目錄 ComponentModelCache,(這是甚麼咚咚?)
位置在
C:\Users\{登入者}\AppData\Local\Microsoft\VisualStudio\10\ComponentModelCache

 重開VS 就OK

2015年5月19日

Android: Eclipse程式專案出現紅色驚嘆號!

前晚救回Eclipse開發平台,今天還有些小問題須解決!

  • 專案x
    原來正常編譯的專案,很多都因為Android-sdk的移除重裝,必須重新指定編譯的Android SDK版本。
  • 專案!驚嘆號
    表示找不到相關的Library。將相關的程式庫放到指定的位置就OK了。


Android: Eclipse ADT Plug-in 升級問題

     將近午夜時,突然心血來潮想試試Android 4.4 KitKat SDK的WebView是否能支援Html5 video 的Playback rate指令,希望可以但一直沒時間測試。就趁這空檔,升級ADT插件和更新下載SDK。因為之前升級一直很順利,心中是有閃過萬一失敗的陰影,但沒放在心上...

2015年3月5日

為善無近名,為惡無近刑

(養生主)
人要活出自己,在不刻意,不影響自主性之下,順便可以讓周遭好。
因其故然。因循原則,因現在的狀況是什麼,全然接受事實的發生,不讓別人牽引著你的情緒。

有效果比有道理有用!

我會有這個現狀,都是我過去自己所創造出來的。
當不滿意時,須反思並知道自己是有辦法解決。

別人的問題,對自己也會有想不到的益處。

與接為構,日以心鬥

與外界接觸糾纏,整天勾心鬥角(內篇齊物論上)

忍住不給答案,陪伴的專家。
陪伴的品質要好,傾聽,我知道我不知道事情。
好奇的問話,分享自己的經驗,尊重別人同不同意你的想法。
敢說會說,說得有效。

2015年1月22日

C#: Strong Name Signature

Checking For A Valid Strong Name Signature
Giving a .NET Assembly a Strong Name


2015年1月2日

Android: NDK不支援有版本資訊的C程式庫?

Issue 55868: NDK: Support for prebuild libs with full sonames

    近日遇到奇怪的問題;好不容易從某Linux Open Sourses原始碼編譯成程式庫.so,正在高興終於編好時,從Andorid載入時竟發生找不到Libxxxx.so.4 程式庫?
    Google半天,終於問對問題找到答案,學會該怎麼serch問題還真是不易呀!
   原來Linux系統的程式庫soname有所謂版本資訊,例如Libxxx.so.4.4.8。Linux用兩個Libxxx.so和Libxxx.so.4(Symbol Link)連結到Libxxx.so.4.4.8,但Android的Linker目前並未支援。若只是將Libxxx.so.4.4.8改名成Libxxx.so複製過去,用 readelf -d Libxxx.so 檢視其soname還是Libxxx.so.4,沒有用的!

2014年12月28日

Android: JNI相關

Java调用C程序, C调用Java程序
JNI Tips
Android 開發筆記 - 使用 NDK / JNI 實作從底層呼叫上層 (C call Java)
Java Programming Tutorial Java Native Interface (JNI)
http://blog.csdn.net/i5suoi/article/details/19036975
探秘腾讯Android手机游戏平台之不安装游戏APK直接启动法
Android应用开发提高系列(4)——Android动态加载(上)——加载未安装APK中的类

2014年12月25日

Android: NDK 測試範例

1. 下載安裝 Android NDK
     例如我將64bits版本的NDK安裝到 E:/dev/SDKs/android-ndk-r9b-windows-x86_64/

2. 下載安裝 Cygwin
     安裝時記得包含Devel中的make 和 Shells中的bash

3. 用Eclipse編譯個簡單的Android Project,內容如下
package com.wsj.android.testjni;
import ......;
public class HelloNDK extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_hello_ndk);
System.loadLibrary("hellondk");    //載入原生程式庫
int result = sayHello();                       //呼叫原生函數 
Log.i("HelloNDK", "" + result);
}
private native int sayHello();           //宣告原生函數
}

2014年12月4日

馬斯奈 Meditation from Thais



IMSLP音樂圖書館 公共領域樂譜

人生的旋轉木馬
開場曲
[3][6]1 3 21[7]1 [6]13 6 654 5
[7]35 76 5(4)565 (4)3 212 32[6][7]
[3][6]1 3 21[7]1 [6]13 66 6754 5
[7]35 76 65(4)(4)(4)65 5(4)3(2)332321
[7](1)(2)3

2014年11月11日

Android: 非UI Thread更動 UI

當Threrad在同個Activity時,蠻方便的作法:

runOnUiThread(new Runnable() {
    @Override
    public void run() {
       // 更新UI.....
    }
  }
);
 

2014年11月8日

Android: 轉換 Immutable Bitmap into Mutable

BitmapFactory.Options options = new BitmapFactory.Options();
options.inMutable = true;  //加上這個選項!!!! (API level 11以上)

Bitmap bm = BitmapFactory.decodeByteArray(data, 0, data.length, options);
Canvas canvas = new Canvas(bm);  // 不然會有錯誤產生!
.......

2014年10月2日

CodeProject : Android 文章