2013年3月20日 星期三

取得Google Map Key v2 MD5&SHA1 Problem

Google Maps Android v1 API Key Signup

MD5還是有辦法取得的!

只要在指令後方加入-v 便大功告成


$ keytool -list -alias androiddebugkey 
-keystore .keystore 
-storepass android -keypass android -v

Android User Interface

1.Layout

  • Linear Layout

  • 指定一個方向,垂直或水平,不管控制項有多大,向下向右排排站

  • Relative Layout

  • 使用相對位置去排版

  • List View

  • Grid View

        這就不用多說了

        Android學習_GridView的使用

Adapter



2.Input Controls



3.Input Events











2013年3月19日 星期二

Google Map API Key



Android筆記_如何申請Google Map API Key(模擬器用)

Android學習_如何申請Google Map API Key(實機用)

Android學習_如何開始使用Google Maps Android API v2

Android Intent



An intent is an abstract description of an operation to be performed. It can be used with startActivity to launch an Activity, broadcastIntent to send it to any interested BroadcastReceiver components, and startService(Intent) or bindService(Intent, ServiceConnection, int) to communicate with a background Service.

An Intent provides a facility for performing late runtime binding between the code in different applications. Its most significant use is in the launching of activities, where it can be thought of as the glue between activities. It is basically a passive data structure holding an abstract description of an action to be performed.

基本上 你知道Intent是什麼拉!

2011年4月28日 星期四

Android應用程式權限問題

一切的起因都是因為android:sharedUserId="android.uid.system"這句指令
使用NDK編譯了一個執行檔D2MCEDaemon
想要直接使用Android應用程式開啟他,但是一直開不起來
後來找到了可以輸出system.out的程式所以才發現原來是權限不足

程式碼是從哪裡找到的已經忘記了
首先在註冊檔上加入android:sharedUserId="android.uid.system"




然後勒
寫一個可以執行底層命令的程式

public class TESTTPERMISSION extends Activity {
 private static final String TAG = "execCommand";
 
 /** Called when the activity is first created. */
 @Override
 public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  setTitle("This is Matrix.");
  
  runRootCommand("/data/local/bin/D2MCEDaemon");
 }
 
 public static boolean runRootCommand(String command) {
        Process process = null;
        DataOutputStream os = null;
            try {
            process = Runtime.getRuntime().exec(command);
           // Log.e("runRootCommand", "su");
            os = new DataOutputStream(process.getOutputStream());
           // os.writeBytes(command+"\n");
            Log.e("runRootCommand", command);
            //os.writeBytes("exit\n");
            os.flush();
            process.waitFor();
            
            String line = null;
            
   InputStream stderr = process.getErrorStream();
   InputStreamReader esr = new InputStreamReader(stderr);
   BufferedReader ebr = new BufferedReader(esr);
   System.out.println("");
   while ((line = ebr.readLine()) != null) {
    System.out.println(line);
    Log.e("runRootCommand", line);
   }
   System.out.println("");

   InputStream stdout = process.getInputStream();
   InputStreamReader osr = new InputStreamReader(stdout);
   BufferedReader obr = new BufferedReader(osr);
   System.out.println("");
   while ((line = obr.readLine()) != null) {
    System.out.println(line);
    Log.e("runRootCommand", line);
   }
   System.out.println("");

            int exitVal = process.waitFor ();
            System.out.println ("Process exitValue: " + exitVal);
            Log.e("runRootCommand", String.valueOf(exitVal));
                                          
            } catch (Exception e) {
                    Log.d("*** DEBUG ***", "Unexpected error - Here is what I know: "+e.getMessage());
                    return false;
            }
            finally {
                    try {
                            if (os != null) {
                                    os.close();
                            }
                            process.destroy();
                    } catch (Exception e) {
                            // nothing
                    }
            }
            return true;
    }

}



明顯的看見我們是想要執行runRootCommand("/data/local/bin/D2MCEDaemon");
這個Command
但是呢
第一個問題
如果沒加上這一行android:sharedUserId="android.uid.system"
他會說permission denied
這讓我頭痛了許多天
第二
加上了android:sharedUserId="android.uid.system"
卻出現
[2011...] Installation error: INSTALL_FAILED_SHARED_USER_INCOMPATIBLE
[2011...] Please check logcat output for more details.
[2011...] Launch canceled!
真的是氣死我了

麻煩的來了
網路上找了一些文章
像是
http://www.wretch.cc/blog/michaeloil/23398272
http://owen-hsu.blogspot.com/2010/09/android-apkuid.html
http://joshzhchen.blogspot.com/2010/09/androidshareduserid.html
http://blog.csdn.net/liujian885/archive/2010/03/22/5404834.aspx
完全看不懂
乖乖的自己去download Android source code之後卻一點頭緒也沒有
至於怎麼download source code
自己去android官網就有教學了
然後自己找了一些有關於signapk的文章
因為上面那些連結根本沒解釋什麼是signapk
好吧
找了一些
http://www.techwen.com/mobile/android/20101215/1422.html
http://www.bangchui.org/read.php?tid=11094
http://hi.baidu.com/langhongjian/blog/item/645a7d2427ecd1144c088d92.html

後來發現是sign的問題

先下載android source code
然後到 cd ~/AndroidSourceCode/build/tools/signapk
再來會看到SignApk.java
執行這一行javac SignApk.java
會出現SignApk$SignatureOutputStream.class和SignApk.class
建立目录s\com\android\signapk在signapk目錄底下
自己慢慢的mkdir
反正要建立完整
再來執行
jar cvfm signapk.jar SignApk.mf -C ./s .

然後會出現signapk.jar
這樣就OK拉~
然後利用Eclipse編譯APK
再專案上右鍵選擇Android tools->Export Unsigned Application Package
這樣就有APK拉~
然後回到linux的signapk目錄底下
執行java -jar signapk.jar platform.x509.pem platform.pk8 input.apk output.apk
大功告成
至於platform.x509.pem platform.pk8在AndroidSourceCode\build\target\product\security目錄底下

然後使用adb install output.apk
終於完成摟

2011年1月21日 星期五

數位項框設定及使用

UBoot>tftp a1100000 uImage
UBoot>protect off 100000 47FFFF
UBoot>erase 100000 47FFFF
UBoot>cp.b a1100000 100000 200000
--
UBoot>tftp a1480000 rootfs.jffs2
UBoot>protect off 480000 137FFFF
UBoot>erase 480000 137FFFF
UBoot>cp.b a1480000 480000 F00000
--
setenv bootcmd run linux
setenv bootdelay 1
--
run linux
--
vi /etc/init.d/rcS
/d2mced & #刪掉
window #刪掉
--
vi /etc/profile
rm -f /task_id_0/*
rm -f /task_id_1/*
/d2mced &
window
--
mkdir 0album
tftp host -g get -r filename

tftp 192.168.0.10 -g get -r img001.jpg
tftp 192.168.0.10 -g get -r img002.jpg
tftp 192.168.0.10 -g get -r img003.jpg
tftp 192.168.0.10 -g get -r img004.jpg
tftp 192.168.0.10 -g get -r img005.jpg
tftp 192.168.0.10 -g get -r img006.jpg
tftp 192.168.0.10 -g get -r img007.jpg
tftp 192.168.0.10 -g get -r img008.jpg
tftp 192.168.0.10 -g get -r img009.jpg
tftp 192.168.0.10 -g get -r img010.jpg
tftp 192.168.0.10 -g get -r img011.jpg
tftp 192.168.0.10 -g get -r img012.jpg
tftp 192.168.0.10 -g get -r img013.jpg
tftp 192.168.0.10 -g get -r img014.jpg
tftp 192.168.0.10 -g get -r img015.jpg
tftp 192.168.0.10 -g get -r img016.jpg
tftp 192.168.0.10 -g get -r img017.jpg
tftp 192.168.0.10 -g get -r img018.jpg

tftp 192.168.0.10 -g get -r pic001.jpg
tftp 192.168.0.10 -g get -r pic002.jpg
tftp 192.168.0.10 -g get -r pic003.jpg
tftp 192.168.0.10 -g get -r pic004.jpg
tftp 192.168.0.10 -g get -r pic005.jpg
tftp 192.168.0.10 -g get -r pic006.jpg
tftp 192.168.0.10 -g get -r pic007.jpg
tftp 192.168.0.10 -g get -r pic008.jpg
--
bootargs=root=/dev/mtdblock3 rw rootfstype=jffs2 console=ttyS0,9600n8 mem=64M ip=192.168.0.101:192.168.0.10:192.168.0.1:255.255.255.0::eth0:off ether=00:16:08:40:13:72
bootargs=root=/dev/mtdblock3 rw rootfstype=jffs2 console=ttyS0,9600n8 mem=64M ip=192.168.0.102:192.168.0.10:192.168.0.1:255.255.255.0::eth0:off ether=00:11:22:33:44:55
bootargs=root=/dev/mtdblock3 rw rootfstype=jffs2 console=ttyS0,9600n8 mem=64M ip=192.168.0.101:192.168.0.10:192.168.0.1:255.255.255.0::eth0:off ether=00:16:f8:40:18:35

2010年11月21日 星期日

framework

在完成Android系統上函式庫層的D2MCE原生碼實作之後,我們將於框架層將設計出方便應用程式開發所用的Java元件。該元件對上提供方便使用的類別與介面及方法,對下則透過JNI與函式庫層的原生碼整合。以下是預計提供的介面類別的宣告與使用方式。


Android D2MCE Java 套件:

import com.eps.d2mce;

說明:Android應用程式引入此套件方可使用D2MCE服務與元件

Android D2MCE執行時期服務取得:

D2MCEManager mD2Mgr = D2MCE.getService("group_name");

說明:若應用程式需使用D2MCE的服務,則透過D2MCE的靜態方法getService()將可加入一名為"group_name"的運算群組。該方法將傳回一D2MCE管理者物件。

Android D2MCE 共享物件宣告與配置

D2MCESharedData mSharedData =

new D2MCESharedData(mD2Mgr, "data_name");

說明:D2MCE將提供一泛形(generic)共享物件類別,在配置共享物件時指定所共享的資料形態(SomeType),建構子中指定D2MCE管理者(代表D2MCE運算群組)與共享資料名稱即可完成配置。(資料大小由SomeType型別決定。)

Android D2MCE 共享物件內容存取

SomeType value = mySharedData.getValue();

mySharedData.setValue(value);

說明:D2MCESharedData類別將提供getValue與setValue方法,用來存取實際型態為SomeType的共享資料內容值。

Android D2MCE 共享物件存取同步方法

mySharedData.lock();

mySharedData.unlock();

說明:D2MCESharedData類別將提供lock與unlock方法,用來實現分散式共享資料存取所需的同步與臨界區間(critical section)運作。(這部分無法使用Java的Synchronized方法與程式區塊的方式實現,而須另行提供,因為我們所面對的環境是分散式的環境,而非單一機器的多執行緒環境。)

以上為Android D2MCE實作應該提供的基本的元件類別。除此之外,我們也應該允許程式開發者透過繼承D2MCESharedData類別的方式來定義自己的共享物件類別;而在資料存取的同步問題,亦可在子類別中定義專用的存取方法,將lock與unlock的同步機制包含於實作中,方便使用。

2010年9月12日 星期日

d2mce_mutex_rw



d2mce_mutex_rw(&mutex, 4, A, "rw", B, "rw", initialized, "rw", schedule_index, "rw");

這是幹嘛用的


其實就是
d2mce_mutex_lock( &mutex);
d2mce_load ( A );
d2mce_load ( initialized);
d2mce_load ( schedule_index );
的合起來


再問一個d2mce_mutex_rw(&mutex, 1,initialized,"r");
這個是什麼組合?

d2mce_mutex_rw(&mutex, 1,initialized,"r");
                   
裡面的 &mutex  是指 mutex_lock 的變數
1 是指 後面有一個 共享變數
那個共享變數叫 initialized

然後 只可以 "r"  = load
rw 就是 可以 load 也可以 store

2010年8月9日 星期一

D2MCE 簡易實作步驟

https://pms.eps.csie.ntut.edu.tw/trac/d2mce/wiki/Reference
https://pms.eps.csie.ntut.edu.tw/svn/d2mce/


d2mce在64bit機器上會壞掉
只能在32bit上執行


首先利用svn下載至電腦上
#apt-get install subversion
#svn co https://pms.eps.csie.ntut.edu.tw/svn/d2mce/


編譯D2MCE
#cd /d2mce/trunk
#./configure --prefix=/opt/d2mce
#make
#make install


要先在home目錄底下mkdir一個.d2mce_conf且裡面要有d2mce.conf
#~/.d2mce_conf/d2mce.conf
這個檔案用來設定用哪一個port哪一個網卡
若沒有這個檔案執行檔案時會出現

root@nisun:/d2mce/trunk/examples/matrix-d2mce-dynamic# ./matrix 
can't not open /root/.d2mce_conf/d2mce.conf
Error: read_config() failed.
d2mce init failured

所以要先做
#cd ~
#mkdir .d2mce_conf
#cd .d2mce_conf

#vim d2mce.conf
編輯內容

network_device eth0
port 55660
然後:wq
port最好大於1024

接下來還要再開一個程式
在/opt/d2mce/bin內的d2mced
這是一個daemon用來控制整個group
所以必須先開daemon
#/opt/d2mce/bin/d2mced

接下來就可以執行程式了
我們執行一個example
#cd /d2mce/trunk/examples/matrix-d2mce-dynamic
#make
#./matrix
可以看到結果

Vector Size:512
Matrix size:262144
Processing time:1.956712
msg count:184
msg byte :5474
daemon exit ok!!


若有error while loading shared libraries: libd2mce.so.0: cannot open shared object file: No such file or directory
需要先在/sbin裡
打ldconfig /opt/d2mce/lib/