Wednesday, January 15, 2014

Start Service return type

START_NOT_STICKY
啟動之後,如果service被kill by system,service不會自動啟動,也不會自動重新傳入intent. 除非開發者有程式呼叫startService(intent)

 START_REDELIVER_INTENT
啟動之後,如果service被kill by system,service會自動啟動,也會自動重新傳入最後一個intent.

START_STICKY
啟動之後,如果service被kill by system,service會自動啟動,但不會自動重新傳入intent. 如果再kill期間,開發者有程式呼叫startService(intent), 才會傳入intent.

START_STICKY_COMPATIBILITY

啟動之後,如果service被kill by system,service不一定會自動啟動, 如果啟動的話,模式與START_STICKY一樣。

Monday, September 23, 2013

Decompile APK

1. Change .APK to .ZIP and unzip it. There is classes.dex in the folder.
2. Download dex2jar(http://code.google.com/p/dex2jar/) to convert classes.dex to classes.
     . dex2jar.sh PATH_TO_CLASSES_DEX/classes.dex
    
    The command should generate classes_dex2jar.jar
3. Download jdgui(http://mac.softpedia.com/dyn-postdownload.php?p=48710&t=4&i=1) to unzip jar file.
    Open jdgui and choose classes_dex2.jar.jar.  All folder and java file should be browsed in JDGUI.  
    Save all source.

4. Download android-apktool(https://code.google.com/p/android-apktool/downloads/list). Choose "apktool1.5.2.tar.bz2" and "apktool-install-macosx-r05-ibot.tar.bz2"(This depends on platform).
    . apktool d PATH_TO_APK/xxx.apk
   All resource and xml file are generated in APK_NAME folder

Friday, June 14, 2013

Compile Android Apps

Command
1. make: compile all Android system
2. make [package name]: the package name can be found in packages/apps/xx/Android.mk
    or
    mmm packages/apps/Package_name
    The APK and odex will generate in out/target/product/generic/system/app/xxx.apk

3. make snod: this command will regenerate system.img
4. Remove default sign key
 
   zip –d xxx.apk META-INF/*

Put 3rd apk into system.img
1. put apk into out/target/product/generic/system/app/
2. make snod


Tuesday, May 28, 2013

Run GCM demo by app engine server

GCM api
1. Create google api project about GCM
2. Create server key. This api key will be used fot setting up server application.

Create App Engine project
1. Apply one project in app engine. Input project name and project url name.
    Peoject url name will be used in Android application.
2. Download App engine SDK for JAVA

  
Set up Server Application
1. Android SDK Manager, install Extras > Google Cloud Messaging for Android Library.
2. In a text editor, edit PATH_TO_ANDOIRD_SDK/extras/google/gcm/samples/gcm-demo-appengine/src/com/google/android/gcm/demo/server/ApiKeyInitializer.java and replace the existing text with the API key obtained above.
3. In a shell window, go to the PATH_TO_ANDOIRD_SDK/extras/google/gcm/samples/gcm-demo-appengine directory.
4. ant -Dsdk.dir=PATH_APP_ENGINE_SDK/appengine-java-sdk-1.8.0/ compile
    It will generate WebContent/. The code will be upload to App engine, so we don't need to launch server in our local side.

Upload Server Application to App Engine
1. From the appengine-java-sdk directory, run:
     bin\appcfg.cmd update PATH_TO_ANDOIRD_SDK/extras/google/gcm/samples/gcm-demo-appengine/WebContent/
2. Open http://appspot.com 
3. It should show "no devices registered" page.

Set up Android Application
  1. Using a text editor, open PATH_TO_ANDOIRD_SDK/extras/google/gcm/samples/gcm-demo-client/src/com/google/android/gcm/demo/app/CommonUtilities.java and set the proper values for the SENDER_ID and SERVER_URL constants.
  2. In a shell window, go to the gcm-demo-client directory.
  3. Use the SDK's android tool to generate the ant build files:
  4. android update project --name GCMDemo -p . --target android-16
4. ant clean debug
5. It will generate GCMDemo-debug.apk in bin/ folder
6. Install APK in devices.
7. Done.

Tuesday, June 26, 2012

Git ignore


  1. Keep your .gitignore file.
  2. Clear your GIT cache.  Don’t worry, this won’t delete any of your local files, just what GIT is tracking.
    git rm -r --cached .
  3. Add everything in your project.  Your .gitignore file will exclude what you want to ignore now and start tracking the good stuff.
    git add .
  4. Commit your changes.
    git commit -m "Now my .gitignore file works correctly!"

Tuesday, April 3, 2012

compile Android Apps

Command
1. make: compile all Android system
2. make [package name]: the package name can be found in packages/apps/xx/Android.mk
or
mmm packages/apps/Package_name
The APK and odex will generate in out/target/product/generic/system/app/xxx.apk
3. make snod: this command will regenerate system.img

Put 3rd apk into system.img
1. put apk into out/target/product/generic/system/app/
2. make snod
or
1. mkdir packages/apps/MyApp
2. vi Android.mk
LOCAL_PATH:=$(call my-dir)
include $(CLEAR_VARS)
LOCAL_POST_PROCESS_COMMAND:=$(shell cp -r $(LOCAL_PATH)/*.apk $TARGET_OUT)/app/)
3. make


Generate AIDL stub
1. make: compile all Android system
2. All system AIDL will convert java code in android_source/out/target/common/obj/JAVA_LIBRARIES/.....

Friday, February 17, 2012

gimap

use telnet to connect gimap.
1. openssl s_client -crlf -connect imap.gmail.com:993
2. . login xxx@gmail.com PASSWORD
3. . list "" "*"
4. use other command. such as close, store, create, delete....