LoginSignup
0
0

More than 3 years have passed since last update.

Android初学者 adbコマンドでターミナルから操作してみた

Last updated at Posted at 2021-01-18

adbコマンドを使ってターミナルからAndroid端末を操作してみた。

インテント直で投げる

adb shell am start -n パッケージ名/アクティビティクラス

adb shell am start -n com.example.bookmanager_android/.MainActivity

上記を叩くと端末を触らなくてもbookmanagerアプリのMainActivityが開く。

Security exception: Permission Denialが出た場合
AndroidManifestファイルの開きたいアクティビティ部分にandroid:exported="true"を追加する。

端末にまかせる

adb shell am start -a アクション -d URL

adb shell am start -a android.intent.action.VIEW -d http://www.google.com/

上記を叩くと端末を触らなくてもgoogleサイトが開く。

おまけ

アプリ側でクエリをもってるとき

adb shell am start -a android.intent.action.VIEW -d testapp.v1://test?open=item\&id=2

testapp.v1://test?open=item&id=2 ⇔ https://www.test.com/jp/item/2 が開く

参考サイト

https://qiita.com/tkc_tsuchiya/items/1fd9953bc1337150dff1
ありがとうございました!

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0