---
title: "Android学习笔记2 "
author: "csbison"
date: "2008-10-06T00:00:00Z"
tags: []
slug: "android-2"
draft: false
lastmod: "2009-10-08T20:21:59Z"
id: 483078
url: "https://csbison.iteye.com/blog/483078"
---

**Android.bat的运行选项**

"list ":           
"list avd":        
"list target":     
"create avd":      
"move avd":        
"delete avd":      
"update avd":      
"create project":  
"update project":  
"update adb":   

 

    **adb.exe的运行选项**

    

**Android Debug Bridge**

Android的调试桥，运行该命令时必须先启动模拟器；然后才可以在模拟器上运行linux命令或安装卸载apk软件。

 

  adb devices                  - list all connected devices

 

device commands:  
  adb push &lt;local&gt; &lt;remote&gt;    - copy file/dir to device  
  adb pull &lt;remote&gt; &lt;local&gt;    - copy file/dir from device  
  adb sync \[ &lt;directory&gt; ]     - copy host-&gt;device only if changed  
                                 (see 'adb help all')  
  adb shell                    - run remote shell interactively  
  adb shell &lt;command&gt;          - run remote shell command  
  adb emu &lt;command&gt;            - run emulator console command  
  adb logcat \[ &lt;filter-spec&gt; ] - View device log  
  adb forward &lt;local&gt; &lt;remote&gt; - forward socket connections  
                                 forward specs are one of:  
                                   tcp:&lt;port&gt;  
                                   localabstract:&lt;unix domain socket name&gt;  
                                   localreserved:&lt;unix domain socket name&gt;  
                                   localfilesystem:&lt;unix domain socket name&gt;  
                                   dev:&lt;character device name&gt;  
                                   jdwp:&lt;process pid&gt; (remote only)  
  adb jdwp                     - list PIDs of processes hosting a JDWP transport

 

  adb install \[-l] \[-r] &lt;file&gt; - push this package file to the device and install it

 

  adb uninstall \[-k] &lt;package&gt; - remove this app package from the device

    -- 这个package名称是在AndroidManifest.xml文件中定义的  
   
scripting:  
  adb wait-for-device          - block until device is online  
  adb start-server             - ensure that there is a server running  
  adb kill-server              - kill the server if it is running  
  adb get-state                - prints: offline | bootloader | device  
  adb get-serialno             - prints: &lt;serial-number&gt;  
  adb status-window            - continuously print device status for a specified device  
  adb remount                  - remounts the /system partition on the device read-write  
  adb root                     - restarts adb with root permissions

 

        **apk文件在模拟器上的安装和卸载**

    

**安装**

    D:\\android\\tools＞adb install c:\\NetScramble\_1.1.apk

**卸载**

    D:\\android\\tools＞adb uninstall bison.sample.helloworld

或者

    D:\\android\\tools＞adb shell rm data/app/NetScramble\_1.1.apk

使用这种办法，可以提高开发调试的速度。

 

    **AndroidManifest.xml文件详解**

    

Android全局配置文件AndroidManifest.xml  
在最外层包含了包名如 package="cn.android123.demo" 、软件的版本号    android:versionCode="1" 以及   android:versionName="1.0" ，里面一层的application分支中将可能包含Android程序的四种对象 Activity、Service、Content Provider以及Receiver。我们每添加上面四个类型中的任一新对象都需要在androidmanifest.xml文件中添加相应节点。

 

其中Activity的属性常用的可能为android:name和android:label但我们需要了解所有的属性以帮助解决复杂的问题，完整的如下:   
          android:allowTaskReparenting=\["true" | "false"]  
          android:alwaysRetainTaskState=\["true" | "false"]  
          android:clearTaskOnLaunch=\["true"" | "false"]  
          android:configChanges=[one or more of: "mcc" "mnc" "locale"  
                                 "touchscreen" "keyboard" "keyboardHidden"  
                                 "navigation" "orientation" "fontScale"]  
          android:enabled=\["true" | "false"]  
          android:excludeFromRecents=\["true" | "false"]  
          android:exported=\["true" | "false"]  
          android:finishOnTaskLaunch=\["true" | "false"]  
          android:icon="drawable resource"  
          android:label="string resource"  
          android:launchMode=["multiple" | "singleTop" |  
                              "singleTask" | "singleInstance"]  
          android:multiprocess=\["true" | "false"]  
          android:name="string"  
          android:noHistory=\["true" | "false"]   
          android:permission="string"  
          android:process="string"  
          android:screenOrientation=["unspecified" | "user" | "behind" |  
                                     "landscape" | "portrait" |  
                                     "sensor" | "nonsensor"]  
          android:stateNotNeeded=\["true" | "false"]  
          android:taskAffinity="string"  
          android:theme="resource or theme"  
          android:windowSoftInputMode=[one or more of: "stateUnspecified"  
                                       "stateUnchanged" "stateHidden"  
                                       "stateAlwaysHidden" "stateVisible"  
                                       "stateAlwaysVisible" "adjustUnspecified"  
                                       "adjustResize" "adjustPan"] &gt;  

 

    **基础知识**

    ·手机屏幕参数的了解  
  市面上常规的机型使用了320x240的 QVGA。N73就是这种分辨率。  
  比如目前使用的是480x320的 HVGA  
  800x480的   WVGA