顯示具有 android 標籤的文章。 顯示所有文章
顯示具有 android 標籤的文章。 顯示所有文章

2012年3月11日 星期日

存取 android market 資料的方法 (二) 第一次爬 Android App Market 就上手 ! Head first crawling Android app market


廢話不多說, 照做以下步驟就可以把整個 market 上的 app 資料都般回家!

開始!


1. 前置準備 

    1.1 一台裝有 Ubuntu 的電腦 

   1.2 並準備好 Ruby on Rails 的環境
          ps. 可參考 http://blog.longwin.com.tw/2008/11/ruby-on-rails-linux-environment-build-2008/ 或網路上任何相關文章 , 此文章是用 Ubuntu 10.04 版

    1.3 安裝 hg
           $sudo add-apt-repository ppa:tortoisehg-ppa/releases
           $sudo add-apt-repository ppa:mercurial-ppa/releases
           $sudo apt-get update
           $sudo apt-get install mercurial python-nautilus tortoisehg

     1.4 下載 source code
           $hg clone https://code.google.com/p/android-marketplace-crawler
           裡頭主要有兩個部分 , 分別是 crawler 以及 server           

2. 準備 crawler 
 
     2.0 安裝 ANT $sudo apt-get install ant
  
     2.1 準備 market-id : 最簡單的方式是在手機上撥打 *#*#8255#*#* 
           會出現如圖畫面 



           請記住紅線部分的字!


     3.1 填入 /crawler/src/com/marketplace/io/Secure.java 中 Secure() , getUsername() , getPassword() 中填妥你的 google 帳號 , 例如 : preferences.put("username_key","你的google帳號");   

     3.2  修改 /crawler/src/com/marketplace/util/Device.java. 中 Device() 的 market id 例如 this.marketId = "你的marketId";

     3.3  修改 /crawler/build.xml 第 38 行
               <fileset dir="/home/你的帳號/android-marketplace-crawler/crawler/bin"/>

     3.3 編譯程式 : $ant          

     3.4 $mv /crawler/permission /path_to_jar_file
           一般情形下 /path_to_jar_file 會在 /crawler/dist/lib 下

4. 準備 server

     4.0 修改 /android-marketplace-crawler/server/Gemfile 如下
           gem 'rake' , '>= 0.9.2' 
           gem 'mysql2', '0.2.18'
           存檔後 , $bundle update
     
    4.1 修改 /config/database.yaml
          增加 socket: /var/run/mysqld/mysqld.sock
          填上 root 之 密碼欄位 
          存檔後 $bundle check,  $bundle install

    4.2 建立資料庫 
          $rake db:create
          $rake db:seed
          $rake db:migrate

    4.3 啟動 Rails server     
          $rails s

5. 開始 crawling! 把資料都搬回家!
    
    切換到剛編譯完的.jar檔所在目錄 
    $java -jar crawler.jar -c


最後, 可以透過瀏覽 http://你的伺服器IP位置:3000 瀏覽目前已經被你爬下來的app資訊!



2011年11月5日 星期六

Installing XMPP Server on Ubuntu Linux

Instant messaging is a popular application in our life ,  most of today's smartphone IM apps are build upon a protocol named XMPP like google talk , Whatsapp , skype ,etc., It it useful to learn how to setup your own XMPP server when we consider to make our app user can chat with some other users on the move (for example: mobile chat room or a mobile MMORPG ) or the real-time server push function (like the Google's C2DM with app engine).

To apply XMPP functionalities to our app , we need to have a server side for handling the account management and message forwarding first.


Here are the steps to install an XMPP server (on Ubuntu Linux):

    and extract :
         #tar -xzvf openfire_3_0_0.tar.gz
           #mv openfire /opt
2. Start Installation Process
    
    a.  #bin/Openfire start
    b.  Insert http://localhost:9090 in your browser to start the web-based wizard
    c.  You will need to have a database system (ex: mysql) on your server that can be accessed by Openfire. Create a table for Openfire when or before you are in the database setup step.   
    d. Now you can access your own XMPP backend server through http://your-domain:9090

We will have our XMPP client in Android platform in the next post !! Have fun !





2011年4月16日 星期六

Android application 中 global 的 data 的處理

開發 Android applications 時我該如何儲存 global 的 data ? 使用平常在開發 Java 時的 singleton pattern 好嗎? 我的 activity 須要跟背景的 service 要資料來更新 UI , 該怎麼作?

2011年3月18日 星期五

存取 android market 資料的方法 (一)

由於論文可能會需要一些關於手機應用程式的相關統計資訊
因此官方的 android market 自然是最直覺想到的對象啦