編輯:關於Android編程
在Android中命令行工具am的用法如下
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
start monitoring: am monitor [--gdb <port>]
--gdb: start gdbserv on the given port at crash/ANR
<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>]
啟動的方法為一個activity
# am start -n 包名/包名.活動(activity)名稱
啟動的哪個acitivity方法可以從每個應用的AndroidManifest.xml的文件中找到信息
啟動音樂
# 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
啟動照相機:
# am start -n com.android.camera/com.android.camera.Camera
啟動浏覽器
# am start -n com.android.browser/com.android.browser.BrowserActivity
啟動浏覽器並上網:
#am start -a android.intent.action.VIEW -d http://www.google.cn/
打電話 :
#am start -a android.intent.action.CALL -d tel:10086
google map 直接定位深圳 :
am start -a android.intent.action.VIEW geo:0,0?q=shenzhen
profile
#ps
#am profile 進程號 start profile_result.txt
#am profile 進程號 stop
啟動一個service
#am startservice service的intent
啟動instrument測試(界面上是進dev tools -->instrument選擇)
看看浏覽器測試工程的xml文件
<application>
<uses-library android:name="android.test.runner" />
</application>
<!--
This declares that this app uses the instrumentation test runner targeting
the package of com.android.email. To run the tests use the command:
"adb shell am instrument -w com.android.browser.tests/android.test.InstrumentationTestRunner"
-->
<instrumentation android:name="android.test.InstrumentationTestRunner"
android:targetPackage="com.android.browser"
android:label="Tests for Browser."/>
<instrumentation android:name="com.android.browser.BrowserLaunchPerformance"
android:targetPackage="com.android.browser"
android:label="Browser Launch Performance">
</instrumentation>
將當前浏覽器加到單元測試中
# am instrument -w com.android.Browser/android.test.InstrumentationTestRunner
運行某個TestCase:
# am instrument -w -e class com.android.BrowserTest.PopularUrlsTest com.android.Browser/android.test.InstrumentationTestRunner
運行一個TestCase中的某個功能:
adb shell am instrument -w -e class com.android.BrowserTest.PopularUrlsTest#testStability com.android.Browser/android.test.InstrumentationTestRunner
同時測試多個TestCase:
#am instrument -w -e class com.android.BrowserTest.PopularUrlsTest,TestWebViewClient.java com.android.Browser/android.test.InstrumentationTestRunner
public class ApiDemosRunner extends InstrumentationTestRunner
{
@Override
public TestSuite getAllTests()
{
Log.i(”ApiDemosRunner”, “ApiDemosRunner::getAllTests()”);
return new TestSuiteBuilder(ApiDemosRunner.class).includeAllPackagesUnderHere().build();
}
@Override
public ClassLoader getLoader()
{
return ApiDemosRunner.class.getClassLoader();
}
}
主題Theme就是用來設置界面UI風格,可以設置整個應用或者某個活動Activity的界面風格。在Android SDK中內置了下面的Theme,可以按標題欄Title
今天在慕課上學了仿微信的滑動,於是就重新敲了代碼在原有的圖形上又增加了改變字體的顏色。這裡將代碼放在這裡便於以後學習。整個過程用了ViewPager與PagerAdapt
先看看效果圖: 第一篇Tab系列的文章首先實現這種風格的底部Tab:背景條顏色不變,我們是用了深灰的顏色,圖標會發生相應的變化,當選中某個標簽後該標簽的背
介紹參考安卓Dialog源碼,他的builder設計模式實現方式是,使用內部類來實現功能,外部類的作用是通過build()函數,來對內部類進行參數設置,例如setter方