新聞中心

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

        Android C編程技巧

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

          emulator -console

        本文引用地址:http://www.104case.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++教程




        關鍵詞:

        評論


        相關推薦

        技術專區

        關閉
        主站蜘蛛池模板: 曲阳县| 台湾省| 思茅市| 商河县| 珲春市| 舟曲县| 清流县| 遵义县| 东乡| 溧水县| 庐江县| 茶陵县| 韶关市| 兴仁县| 丘北县| 洪雅县| 平阴县| 阳山县| 即墨市| 武平县| 客服| 富川| 腾冲县| 仙游县| 饶阳县| 五指山市| 松江区| 富川| 商城县| 佛坪县| 莱州市| 银川市| 卢湾区| 桂阳县| 水城县| 紫云| 普陀区| 厦门市| 武汉市| 大英县| 江油市|