惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Google Online Security Blog
Google Online Security Blog
博客园_首页
酷 壳 – CoolShell
酷 壳 – CoolShell
Jina AI
Jina AI
博客园 - Franky
大猫的无限游戏
大猫的无限游戏
Hugging Face - Blog
Hugging Face - Blog
博客园 - 司徒正美
V
V2EX
雷峰网
雷峰网
云风的 BLOG
云风的 BLOG
V
Visual Studio Blog
F
Full Disclosure
Y
Y Combinator Blog
V
V2EX - 技术
Attack and Defense Labs
Attack and Defense Labs
S
Security @ Cisco Blogs
Schneier on Security
Schneier on Security
Microsoft Azure Blog
Microsoft Azure Blog
SecWiki News
SecWiki News
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
The GitHub Blog
The GitHub Blog
量子位
PCI Perspectives
PCI Perspectives
S
Secure Thoughts
D
Darknet – Hacking Tools, Hacker News & Cyber Security
AWS News Blog
AWS News Blog
Blog — PlanetScale
Blog — PlanetScale
爱范儿
爱范儿
K
Kaspersky official blog
B
Blog
A
Arctic Wolf
Hacker News: Ask HN
Hacker News: Ask HN
L
LangChain Blog
T
Tor Project blog
P
Privacy & Cybersecurity Law Blog
Recent Announcements
Recent Announcements
宝玉的分享
宝玉的分享
The Register - Security
The Register - Security
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
L
Lohrmann on Cybersecurity
D
Docker
A
About on SuperTechFans
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Google DeepMind News
Google DeepMind News
The Last Watchdog
The Last Watchdog
S
Security Affairs
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Privacy International News Feed
Simon Willison's Weblog
Simon Willison's Weblog

博客园 - Titan

[ZZ]产品经理的核心价值 【ZZ】产品经理如何推进团队执行力 [转载]我在QQ邮箱的这四年 关于草根小团队创业的一些看法【转】 狗日的腾讯对蛋疼的360 使用Doxygen来自动化生成项目代码文档 [转载]Visual Studio统计有效代码行数 把东西写下来是一种神奇的力量 [转载]论我国的期股、期权激励制度 [转载]组态软件的发展和趋势 [转载]现阶段HMI市场发展趋势分析 自动化组态软件市场的趋势与挑战 [转载]风力发电自动化市场容量和增长预测 转载《2009年度组态软件市场研究报告》读后感 [ZZ]解析Windows 7超级任务栏 IE8 RC1使用体验 Windows 7 Beta hotkey cheat sheet [ZZ]Redirecting Output to a File in Windows Batch Scripts 欧洲通行证
在Android模拟器上安装和卸载APK包
Titan · 2011-07-05 · via 博客园 - Titan

在Android模拟器上安装和卸载APK包

【安装APK】
    安装APK当然首先是要有模拟器,和要安装的APK包。

    首先,将模拟器执行起来,直到正式进入系统。
    接下来,打开一个cmd窗口,路径切换到模拟器目录下的tools目录。
    输入:adb install 你要安装的apk文件的路径。

    如果看到一行类显示传输速度的文字,那说明安装成功了。如下:
    C:/Documents and Settings/Administrator>cd D:/andriod/tools

    C:/Documents and Settings/Administrator>d:

    D:/android/tools>adb install c:/NetScramble_1.1.apk 100 KB/s (0 bytes in 164464.001s)

    回到Android模拟器的界面,我本来以为可以看到刚刚安装的APK程序图标,结果,却根本没有...后来研究了一下,发现这根APK包自身有关。使用 自己编写的HelloAndroid安装,图标就可以显示在桌面上,而NetScramble_1.1.apk安装后却显示不出来。具体原因是来自于 AndroidManifest.xml文件的内容。

  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android "  package="net.xiashou.android">  
  3.     <application android:icon="@drawable/icon">  
  4.     <activity android:name=".HelloAndroid" android:label="@string/app_name">  
  5.         <intent-filter>  
  6.             <action android:name="android.intent.action.MAIN" />  
  7.             <category android:name="android.intent.category.LAUNCHER" />  
  8.        </intent-filter>  
  9.     </activity>  
  10.     </application>  
  11. </manifest>  

    xml文件中,红色一行是表示这个apk属于哪个归类里,如果不正确的填写这个信息,Launcher将不会将其显示在桌面上,因为它会认为这个应用部署以自己的归类。

    那么,是不是我们就无法执行缺失了category的apk了呢?

    后来,在一个老外的blog上,查到了方法:在shell内使用am来加载android应用

  1. usage: am [start|instrument]  
  2.        am start [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>] [-c <CATEGORY> [-c <CATEGORY>] ...]   
  3.                 [-e <EXTRA_KEY> <EXTRA_VALUE> [-e <EXTRA_KEY> <EXTRA_VALUE> ...] [-n <COMPONENT>] [-D] [<URI>]  
  4.        am instrument [-e <ARG_NAME> <ARG_VALUE>] [-p <PROF_FILE>] [-w] <COMPONENT>  

    比如启动一个manifest为如下内容的apk

  1. <?xml version="1.0" encoding="utf-8"?>  
  2. <manifest xmlns:android="http://schemas.android.com/apk/res/android " package="net.xiashou.android">  
  3.      <application android:icon="@drawable/icon">  
  4.      <activity android:name=".HelloAndroid" android:label="@string/app_name">  
  5.           <intent-filter>  
  6.               <action android:name="android.intent.action.MAIN" />  
  7.               <category android:name="android.intent.category.LAUNCHER" />  
  8.           </intent-filter>  
  9.     </activity>  
  10.     </application>  
  11. </manifest>  

    使用的指令为:

    am start -n net.xiashou.android/net.xiashou.android.HelloAndroid

    还有一些很有用处的用法

    直接启动浏览器打开一个网址 # am start -a android.intent.action.VIEW -d http://snowyrock.spaces.live.com

    拨打电话 # am start -a android.intent.action.CALL -d tel:10086 启动google map直接定位在天津 # am start -a android.intent.action.VIEW geo:0,0?q=tianjin

    am很可能将来成为第三方lancher的基础。

【卸装APK】

    与安装类似的,卸妆是利用adb执行一个卸妆指令:

    D:/android/tools>adb shell rm data/app/NetScramble_1.1.apk

    这里,也可以看出,Android系统是将第三方应用放在data/app目录内的。