Android通过adb启动应用

在Android中,除了从界面上启动程序之外,还可以从命令行启动程序,使用的是命令行工具am.

usage: am [subcommand] [options]  
    start an Activity: 
        am start [-D]  -D: enable debugging  
    send a broadcast Intent: 
        am broadcast  
    start an Instrumentation: 
        am instrument [flags] 
            -r: print raw results (otherwise decode REPORT_KEY_STREAMRESULT)         
            -e : set argument to 
            -p : write profiling data to 
            -w: wait for instrumentation to finish before returning  
    start profiling: 
        am profile start     
    stop profiling: 
        am profile stop  
    specifications include these flags:
             [-a ] [-d ] [-t ]         
             [-c [-c ] ...]         
             [-e|--es ...]         
             [--ez ...]         
             [-e|--ei ...]         
             [-n ] [-f ] []  

启动的方法为

      $ adb shell 
      $ am start -n {包(package)名}/{包名}.{活动(activity)名称}

例如,启动包名为com.example.wdy.classifier的应用,启动命令如下:

am start -n com.example.wdy.classifier/com.example.wdy.classifier.MainActivity

你可能感兴趣的:(安卓源码开发问题)