---
title: "andriod模拟器环境下apk应用程序的安装和删除"
author: "rayloo"
date: "2009-06-17T17:49:00Z"
tags: []
slug: "andriod-apk"
draft: false
lastmod: "2009-06-17T17:49:00Z"
id: 1008857
url: "https://rayloo.iteye.com/blog/1008857"
---

- 1.安装Android程序
  
  1).启动模拟器，emulator；  
  2).通过adb install \*.apk其实将apk文件上传到了模拟器自带操作系统的data/app目录下了；  
  3).可以在android的界面下打开apk应用程序了
  
  2.删除Android应用程序
  
  如果要卸载apk却没有提供adb uninstall这个命令，要移除只好进入模拟器操作系统的文件系统内部手动删除apk文件了。如何做？运行adb shell 可进入模拟器自带的操作系统，然后的操作和Linux一样：cd data/app ; rm HelloAndroid.apk ;就可以了。下次就不会再见到这个Android程序了。

<!--THE END-->

- 【IT168 技术文档】在Android中，除了从界面上启动程序之外，还可以从命令行启动程序，使用的是命令行工具am .  
  启动的方法为  
  　　# am start -n ｛包(package)名｝ /｛包名｝ .{活动(activity )名称}
  
  启动的方法可以从每个应用的AndroidManifest.xml的文件中得到，以[计算器](http://product.it168.com/list/b/0342_1.shtml "计算器") （ calculator ）为例，它的  
  &lt;?xml version="1.0" encoding="utf-8"?&gt;  
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"  
  package="com.android.calculator2 "&gt;  
  &lt;application android:label="@string/app\_name" android:icon="@drawable/icon"&gt;  
  &lt;activity android:name="Calculator "  
  android:theme="@android:style/Theme.Black"&gt;  
  &lt;intent-filter&gt;  
  &lt;action android:name="android.intent.action.MAIN" /&gt;  
  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;  
  &lt;/intent-filter&gt;  
  &lt;/activity&gt;  
  &lt;/application&gt;  
  &lt;/manifest&gt;
  
  由此计算器 （ calculator ） 的启动方法为：  
  \# am start -n com.android.calculator2 /com.android.calculator2 .Calculator
  
  对于HelloActivity这个示例工程，AndroidManifest.xml如下所示：  
  &lt;?xml version="1.0" encoding="utf-8"?&gt;  
  &lt;manifest xmlns:android=" [http://schemas.android.com/apk/res/android](http://schemas.android.com/apk/res/android) "
  
  package="com .example.android.helloactivity "&gt;  
  &lt;application android:label="Hello, Activity!"&gt;  
  &lt; activity android:name="HelloActivity" &gt;  
  &lt;intent-filter&gt;  
  &lt;action android:name="android.intent.action.MAIN"/&gt;  
  &lt;category android:name="android.intent.category.LAUNCHER"/&gt;  
  &lt;/intent-filter&gt;  
  &lt;/activity&gt;  
  &lt;/application&gt;  
  &lt;/manifest&gt;
  
  由此 它 的启动方法为：  
  \# am start -n com.example.android.helloactivity/com.example.android.helloactivity.HelloActivity
  
  其他的一些应用启动命令，如下所示：
  
  calendar （日历）的启动方法为：  
  \# am start -n com.android.calendar/com.android.calendar.LaunchActivity
  
  AlarmClock （闹钟）的启动方法为：  
  \# am start -n com.android.alarmclock/com.android.alarmclock.AlarmClock
  
  Music 和 Video （音乐和[视频](http://movie.it168.com/ "视频") ）的启动方法为：  
  \# am start -n com.android.music/com.android.music.MusicBrowserActivity  
  \# am start -n com.android.music/com.android.music.VideoBrowserActivity  
  \# am start -n com.android.music/com.android.music.MediaPlaybackActivity
  
  Camera（照相机） 的启动方法为：  
  \# am start -n com.android.camera/com.android.camera.Camera
  
  Browser （浏览器）的启动方法为：  
  \# am start -n com.android.browser/com.android.browser.BrowserActivity
  
  　　一般情况希望，一个Android应用对应一个工程。值得注意的是，有一些工程具有多个活动（ activity ），而有一些应用使用一个工程。例如：在Android界面中， Music和Video是两个应用，但是它们使用的都是packages/apps/Music这一个工程。而在 这个工程 的 AndroidManifest.xml文件中，有包含了不同的 活动（ activity ）。