📜 元の英語説明(参考)
Control Android devices via Termux API over SSH. Access camera, sensors, location, notifications, SMS, clipboard, TTS, and 70+ other device APIs. Requires Termux and Termux:API installed on the Android device.
※ 原文(英語/中国語)を Gemini で日本語化したものです。Claude 自身は原文を読みます。誤訳がある場合は原文をご確認ください。
Termux API Skill
SSH経由でTermux APIコマンドを使用してAndroidデバイスを制御します。
前提条件
- AndroidデバイスにTermuxがインストールされていること
- Termux:APIアプリがインストールされ、権限が付与されていること
- SSHアクセスが設定されていること(デフォルトではポート8022)
termux-apiパッケージがインストールされていること: pkg install termux-api
接続
# デフォルトのSSH接続
ssh -p 8022 <device-ip> '<termux-api-command>'
重要な注意事項
- カメラ/マイクコマンドの場合、Termuxがフォアグラウンドにある必要があります。
- 権限はAndroid設定 → Termux:API → 権限で付与する必要があります。
- コマンドがタイムアウトする場合は、APIサービスを開始してください:
termux-api-start
APIコマンドリファレンス
デバイス情報
| コマンド |
説明 |
termux-battery-status |
バッテリーレベル、充電ステータス、温度 |
termux-audio-info |
オーディオデバイス情報 |
termux-wifi-connectioninfo |
現在のWiFi接続の詳細 |
termux-wifi-scaninfo |
周囲のWiFiネットワークをスキャン |
termux-telephony-deviceinfo |
電話/SIM情報 |
termux-telephony-cellinfo |
携帯電話基地局情報 |
termux-sensor -l |
利用可能なセンサーを一覧表示 |
termux-sensor -s <sensor> -n 1 |
センサーを一度読み取る |
カメラとメディア
| コマンド |
説明 |
termux-camera-info |
カメラを一覧表示(id 0=背面、1=前面) |
termux-camera-photo -c <id> <file.jpg> |
写真を撮る(フォアグラウンドが必要) |
termux-microphone-record -f <file> |
音声を録音 |
termux-media-player play <file> |
オーディオファイルを再生 |
termux-tts-speak "text" |
テキスト読み上げ |
termux-tts-engines |
TTSエンジンを一覧表示 |
通知とフィードバック
| コマンド |
説明 |
termux-notification -t "title" -c "content" |
通知を表示 |
termux-notification-remove --id <id> |
通知を削除 |
termux-toast "message" |
トーストポップアップを表示 |
termux-vibrate -d <ms> |
指定した時間だけ振動 |
termux-torch on/off |
フラッシュライトのオン/オフを切り替える |
termux-dialog |
ダイアログを表示(様々なタイプ) |
通信(権限が必要)
| コマンド |
説明 |
termux-sms-list -l 10 |
最近のSMSを一覧表示 |
termux-sms-send -n <number> "message" |
SMSを送信 |
termux-contact-list |
連絡先を一覧表示 |
termux-call-log -l 10 |
最近の通話履歴 |
termux-telephony-call <number> |
電話をかける |
クリップボード
| コマンド |
説明 |
termux-clipboard-get |
クリップボードの内容を取得 |
termux-clipboard-set "text" |
クリップボードを設定 |
位置情報
| コマンド |
説明 |
termux-location |
GPS位置情報を取得(権限が必要) |
termux-location -p gps |
GPSプロバイダーを使用 |
termux-location -p network |
ネットワークプロバイダーを使用 |
システム制御
| コマンド |
説明 |
termux-volume |
音量レベルを取得/設定 |
termux-brightness <0-255> |
画面の明るさを設定 |
termux-wallpaper -f <file> |
壁紙を設定 |
termux-wake-lock |
スリープを防止 |
termux-wake-unlock |
スリープを許可 |
ストレージと共有
| コマンド |
説明 |
termux-share -a send <file> |
Androidインテント経由でファイルを共有 |
termux-open <file> |
デフォルトのアプリでファイルを開く |
termux-open-url <url> |
ブラウザでURLを開く |
termux-download <url> |
ファイルをダウンロード |
termux-storage-get <dest> |
ストレージからファイルを選択 |
一般的なパターン
自撮り写真を撮って取得する
# まずTermuxがフォアグラウンドにあることを確認します
adb shell am start -n com.termux/.HomeActivity
# 写真を撮る
ssh -p 8022 <ip> 'termux-camera-photo -c 1 ~/selfie.jpg'
# SCP経由で取得
scp -P 8022 <ip>:~/selfie.jpg /local/path/
アクション付き通知を送信する
ssh -p 8022 <ip> 'termux-notification -t "Alert" -c "Task complete" --id myalert --vibrate 200,100,200'
デバイスの位置情報を取得する
ssh -p 8022 <ip> 'termux-location -p network'
# 緯度、経度、精度を含むJSONを返します
バッテリーを監視する
ssh -p 8022 <ip> 'termux-battery-status' | jq '.percentage, .status'
トラブルシューティング
コマンドがタイムアウトする
- APIサービスを開始します:
termux-api-start
- Termux:APIアプリがインストールされているか確認します。
- カメラ/マイクの場合: Termuxアプリがフォアグラウンドにあることを確認します。
権限が拒否される
- Android設定 → アプリ → Termux:API → 権限を開きます。
- 必要な権限(カメラ、位置情報、SMSなど)を付与します。
SSH接続が拒否される
- Termuxで:
pkg install openssh && sshd
- SSHはデフォルトでポート8022で実行されます。
passwdでパスワードを設定するか、SSHキーを~/.ssh/authorized_keysに追加します。
📜 原文 SKILL.md(Claudeが読む英語/中国語)を展開
Termux API Skill
Control Android devices via Termux API commands over SSH.
Prerequisites
- Termux installed on Android device
- Termux:API app installed and permissions granted
- SSH access configured (port 8022 by default)
termux-api package installed: pkg install termux-api
Connection
# Default SSH connection
ssh -p 8022 <device-ip> '<termux-api-command>'
Important Notes
- Termux must be in foreground for camera/microphone commands
- Permissions must be granted in Android Settings → Termux:API → Permissions
- Start API service if commands timeout:
termux-api-start
API Commands Reference
Device Info
| Command |
Description |
termux-battery-status |
Battery level, charging status, temperature |
termux-audio-info |
Audio device info |
termux-wifi-connectioninfo |
Current WiFi connection details |
termux-wifi-scaninfo |
Scan nearby WiFi networks |
termux-telephony-deviceinfo |
Phone/SIM info |
termux-telephony-cellinfo |
Cell tower info |
termux-sensor -l |
List available sensors |
termux-sensor -s <sensor> -n 1 |
Read sensor once |
Camera & Media
| Command |
Description |
termux-camera-info |
List cameras (id 0=back, 1=front) |
termux-camera-photo -c <id> <file.jpg> |
Take photo (needs foreground) |
termux-microphone-record -f <file> |
Record audio |
termux-media-player play <file> |
Play audio file |
termux-tts-speak "text" |
Text to speech |
termux-tts-engines |
List TTS engines |
Notifications & Feedback
| Command |
Description |
termux-notification -t "title" -c "content" |
Show notification |
termux-notification-remove --id <id> |
Remove notification |
termux-toast "message" |
Show toast popup |
termux-vibrate -d <ms> |
Vibrate for duration |
termux-torch on/off |
Toggle flashlight |
termux-dialog |
Show dialog (various types) |
Communication (needs permissions)
| Command |
Description |
termux-sms-list -l 10 |
List recent SMS |
termux-sms-send -n <number> "message" |
Send SMS |
termux-contact-list |
List contacts |
termux-call-log -l 10 |
Recent call history |
termux-telephony-call <number> |
Make phone call |
Clipboard
| Command |
Description |
termux-clipboard-get |
Get clipboard content |
termux-clipboard-set "text" |
Set clipboard |
Location
| Command |
Description |
termux-location |
Get GPS location (needs permission) |
termux-location -p gps |
Use GPS provider |
termux-location -p network |
Use network provider |
System Control
| Command |
Description |
termux-volume |
Get/set volume levels |
termux-brightness <0-255> |
Set screen brightness |
termux-wallpaper -f <file> |
Set wallpaper |
termux-wake-lock |
Prevent sleep |
termux-wake-unlock |
Allow sleep |
Storage & Sharing
| Command |
Description |
termux-share -a send <file> |
Share file via Android intent |
termux-open <file> |
Open file with default app |
termux-open-url <url> |
Open URL in browser |
termux-download <url> |
Download file |
termux-storage-get <dest> |
Pick file from storage |
Common Patterns
Take a selfie and retrieve it
# Ensure Termux is in foreground first
adb shell am start -n com.termux/.HomeActivity
# Take photo
ssh -p 8022 <ip> 'termux-camera-photo -c 1 ~/selfie.jpg'
# Retrieve via SCP
scp -P 8022 <ip>:~/selfie.jpg /local/path/
Send notification with action
ssh -p 8022 <ip> 'termux-notification -t "Alert" -c "Task complete" --id myalert --vibrate 200,100,200'
Get device location
ssh -p 8022 <ip> 'termux-location -p network'
# Returns JSON with latitude, longitude, accuracy
Monitor battery
ssh -p 8022 <ip> 'termux-battery-status' | jq '.percentage, .status'
Troubleshooting
Command times out
- Start API service:
termux-api-start
- Check if Termux:API app is installed
- For camera/mic: ensure Termux app is in foreground
Permission denied
- Open Android Settings → Apps → Termux:API → Permissions
- Grant required permissions (camera, location, SMS, etc.)
SSH connection refused
- In Termux:
pkg install openssh && sshd
- SSH runs on port 8022 by default
- Set password with
passwd or add SSH key to ~/.ssh/authorized_keys