Mobile/Android

[Android] adb를 이용하여 action 하기

out of coding 2017. 1. 23. 17:54

그냥 대략 adb를 사용하면, 개발할때 편한 부분이 있을수가 있다.

대략적인 부분은 다음과 같고, 응용하여 사용하기 바랍니다.

 

1. Activity 실행

adb shell am start -a android.intent.action.MAIN -n 패키지명/액티비티 경로명

Ex) adb shell am start -a android.intent.action.MAIN -n com.exam.test/com.exam.test.MainActivity


2. Service 실행

adb shell am startservice -n 패키지명/서비스경로명

Ex) adb shell am startservice -n com.exam.test/com.exam.test.MainService


3. Broadcast 실행

adb shell am broadcast -a "브로드캐스트명"

Ex) adb shell am broadcast -a android.accounts.LOGIN_ACCOUNTS_CHANGED

 

4. adb restart

adb kill-server

adb start-server


5. adb에 연결된 device list

adb devices


6. 특정 device를 선택해서 사용

adb -d shell (device)

adb -e shell (emulator)

adb -s [device-name] shell (device serial)


7. apk 설치

adb -d install test.apk


8. 재설치

adb -d install -r test.apk


9. sign 오류로 재설치가 안될 경우

adb -d push test.apk /system/app


10. 텍스트를 입력하여줌.

adb shell input text "애국가"


11. 갤러리 실행 

adb shell am start -a android.intent.action.GET_CONTENT -t image/jpeg  


12. 카메라 실행 

adb shell am start -a android.media.action.IMAGE_CAPTURE


13. 환경설정 실행

adb shell am start -a android.intent.action.MAIN -n com.android.settings/.Settings


14. Scheme로 실행

adb shell am start -a android.intent.action.VIEW customscheme://