久久ER99热精品一区二区-久久精品99国产精品日本-久久精品免费一区二区三区-久久综合九色综合欧美狠狠

新聞中心

EEPW首頁 > 嵌入式系統 > 專題 > Android C編程技巧

Android C編程技巧

作者: 時間:2008-11-17 來源:IT168 收藏
運行模擬器

  emulator -console

本文引用地址:http://cqxgywz.com/article/89569.htm

  * 將文件寫入到模擬器的userdata.img文件中

  adb push

  *將一個目錄拷貝到模擬器中,包括子目錄

  adb push

  * 將一個目錄從模擬器中拷出來

  adb pull

  * 使得模擬器可以運行arm代碼.

  使用GNU/ARM Linux編譯器編譯你的應用程序就可以了

  * 在模擬器里面運行shell,需要先運行模擬器

  adb shell

  *運行模擬器中的一個控制臺程序

  adb shell

  *連接模擬器的控制臺

  telnet localhost 5554/6/8

  運行C程序

  參考文獻

  Native C "Hello World" working in emulator

  http://groups.google.com/group/a ... wse_thread/threa...

  Native C Applications for Android

  http://benno.id.au/blog/2007/11/13/android-native-apps

  步驟

  * 下載GNU/ARM編譯工具

  http://www.codesourcery.com/gnu_toolchains/arm/download.html

  * 編寫c/c++代碼.

  * 使用GNU/ARM Linux 工具創建一個應用程序,不使用動態鏈接庫

  ex. arm-none-linux-gnueabi-g++.exe -static -o hello HelloAndroid.cpp

  * 啟動模擬器

  $SDK_ROOT/tools/emulator.exe

  * 在命令行窗口運行 abd將編譯好的hello程序放入模擬器的磁盤

  adb push hello /system/sbin/hello

  * 讓hello文件變成可執行程序,不要使用 chmod ugo+x

  adb shell chmod 777 /system/sbin/hello

  * 運行hello程序

  adb shell

  cd /system/sbin/

  hello

  EXAMPLE HELLO WORLD CODE

  //   // HelloAndroid.cpp   //   //   #include   using std::cin;   using std::cout;   using std::endl;   class MyName   {   public:   void getname( void );   void sayhello( void );   private:   char name[ 255 ];   };   void MyName::getname( void )   {   cout << "What is your name? ";   cin >> name;   }   void MyName::sayhello( void )   {   cout << "Welcome " << name << " to the world of Android" << endl;   }   MyName name;   int main( int argc, char *argv[] )   {   name.getname();   name.sayhello();   return 0;   }

c++相關文章:c++教程




關鍵詞:

評論


相關推薦

技術專區

關閉