<meter id="pryje"><nav id="pryje"><delect id="pryje"></delect></nav></meter>
          <label id="pryje"></label>

          新聞中心

          EEPW首頁 > 嵌入式系統(tǒng) > 專題 > Android C編程技巧

          Android C編程技巧

          作者: 時(shí)間:2008-11-17 來源:IT168 收藏
          運(yùn)行模擬器

            emulator -console

          本文引用地址:http://www.ex-cimer.com/article/89569.htm

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

            adb push

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

            adb push

            * 將一個(gè)目錄從模擬器中拷出來

            adb pull

            * 使得模擬器可以運(yùn)行arm代碼.

            使用GNU/ARM Linux編譯器編譯你的應(yīng)用程序就可以了

            * 在模擬器里面運(yùn)行shell,需要先運(yùn)行模擬器

            adb shell

            *運(yùn)行模擬器中的一個(gè)控制臺程序

            adb shell

            *連接模擬器的控制臺

            telnet localhost 5554/6/8

            運(yùn)行C程序

            參考文獻(xiàn)

            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 工具創(chuàng)建一個(gè)應(yīng)用程序,不使用動(dòng)態(tài)鏈接庫

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

            * 啟動(dòng)模擬器

            $SDK_ROOT/tools/emulator.exe

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

            adb push hello /system/sbin/hello

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

            adb shell chmod 777 /system/sbin/hello

            * 運(yùn)行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++相關(guān)文章:c++教程




          關(guān)鍵詞:

          評論


          相關(guān)推薦

          技術(shù)專區(qū)

          關(guān)閉
          看屁屁www成人影院,亚洲人妻成人图片,亚洲精品成人午夜在线,日韩在线 欧美成人 (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })();