JAVA

adb shell 어플 실행

ndlessrain 2013. 8. 26. 11:11
728x90

어플상에서 ADB명령어 입력하는 방법!



예를 들어, ADB상에서 

> adb shell

# am start -a Intent.ACTION_SEND -t text/x-vCalendar -n com.android.bluetooth.LauncherActivity


대략 이런 정도의 명령어를 날린다고 할 때, 이를 App 단에서 실행할 수 있는 방법.


==========================================================================================================================

 

String[] cmd = {"am", "start", "-a", " Intent.ACTION_SEND ", "-t", " text/x-vCalendar ",  "-n", " LauncherActivity"}; 

try {

Runtime runtime = Runtime.getRuntime();

runtime.exec(cmd);

} catch (IOException e) {

Log.v(TAG, "IOException");

e.printStackTrace();

}

 

==========================================================================================================================


이렇게 해주면 된다.


각각의 명령어 당 배열 1칸을 할당해 주어야 하며, 띄어쓰기로 한번에 쓰면 안된다.




아래는 adb 명령어 정리.


usage: am [subcommand] [options]

    start an Activity: am start [-D] [-W] < INTENT>
        -D: enable debugging
        -W: wait for launch to complete

    start a Service: am startservice <INTENT>

    send a broadcast Intent: am broadcast <INTENT>

    start an Instrumentation: am instrument [flags] <COMPONENT>
        -r: print raw results (otherwise decode REPORT_KEY_STREAMRESULT)
        -e < NAME> <VALUE>: set argument <NAME> to < VALUE>
        -p <FILE>: write profiling data to < FILE>
        -w: wait for instrumentation to finish before returning

    start profiling: am profile <PROCESS> start < FILE>
    stop profiling: am profile <PROCESS> stop

    < INTENT> specifications include these flags:
        [-a < ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]
        [-c < CATEGORY> [-c <CATEGORY>] ...]
        [-e|--es < EXTRA_KEY> <EXTRA_STRING_VALUE> ...]
        [--esn < EXTRA_KEY> ...]
        [--ez <EXTRA_KEY> < EXTRA_BOOLEAN_VALUE> ...]
        [-e|--ei <EXTRA_KEY> < EXTRA_INT_VALUE> ...]
        [-n <COMPONENT>] [-f < FLAGS>]
        [--grant-read-uri-permission] [--grant-write-uri-permission]
        [--debug-log-resolution]
        [--activity-brought-to-front] [--activity-clear-top]
        [--activity-clear-when-task-reset] [--activity-exclude-from-recents]
        [--activity-launched-from-history] [--activity-multiple-task]
        [--activity-no-animation] [--activity-no-history]
        [--activity-no-user-action] [--activity-previous-is-top]
        [--activity-reorder-to-front] [--activity-reset-task-if-needed]
        [--activity-single-top]
        [--receiver-registered-only] [--receiver-replace-pending]
        [<URI>]

 




자료는 마음껏 수정하시고 퍼가셔도 좋습니다. 단, 출처를 꼭 남겨주세요.

출처 : http://www.mfamstory.com

728x90