インストールされているアプリの起動時間や終了時間などのログ

962 views
Skip to first unread message

りあむ

unread,
Nov 18, 2015, 5:06:54 PM11/18/15
to 日本Androidの会

Androidの開発を行っています。
自分がインストールしているアプリの使用状況を出力するようなアプリを作っています
Androidで自分のインストールされているアプリを起動した時間や終了した時間などを取得したいのですが
ログはどこに保存されますか?

またそれを取得することは可能ですか?

taro_h

unread,
Nov 19, 2015, 2:26:22 AM11/19/15
to 日本Androidの会
学生部の濱中と申します。

adb shell dumpsys procstats
このADBコマンドで利用統計が出力できます。
この出力結果を文字列処理すればできるのでは無いのでしょうか。

出力内容は以下のサイトが参考になると思います。

未確認ですが、OSのバージョンにより出力結果の項目に違いが出る場合があるので、お気をつけ下さい。
参考までに、dumpsys procstatsのオプションです。

shell@flo:/ $ dumpsys procstats -h
Process stats (procstats) dump options:
    [--checkin|-c|--csv] [--csv-screen] [--csv-proc] [--csv-mem]
    [--details] [--full-details] [--current] [--hours N] [--last N]
    [--max N] --active] [--commit] [--reset] [--clear] [--write] [-h]
    [--start-testing] [--stop-testing] [<package.name>]
  --checkin: perform a checkin: print and delete old committed states.
  -c: print only state in checkin format.
  --csv: output data suitable for putting in a spreadsheet.
  --csv-screen: on, off.
  --csv-mem: norm, mod, low, crit.
  --csv-proc: pers, top, fore, vis, precept, backup,
    service, home, prev, cached
  --details: dump per-package details, not just summary.
  --full-details: dump all timing and active state details.
  --current: only dump current state.
  --hours: aggregate over about N last hours.
  --last: only show the last committed stats at index N (starting at 1).
  --max: for -a, max num of historical batches to print.
  --active: only show currently active processes/services.
  --commit: commit current stats to disk and reset to start new stats.
  --reset: reset current stats, without committing.
  --clear: clear all stats; does both --reset and deletes old stats.
  --write: write current in-memory stats to disk.
  --read: replace current stats with last-written stats.
  --start-testing: clear all stats and starting high frequency pss sampling.
  --stop-testing: stop high frequency pss sampling.
  -a: print everything.
  -h: print this help text.
  <package.name>: optional name of package to filter output by.

2015年11月19日木曜日 7時06分54秒 UTC+9 りあむ:

Makoto Yamazaki

unread,
Nov 19, 2015, 4:54:59 AM11/19/15
to android-g...@googlegroups.com
zaki です。

API 21 から UsageStatsManager が追加されました。
ユーザーに対して設定画面から情報の取得の許可の操作をしてもらう必要がありますが、
これでかなり細かいところまで取得できるとおもいます。


--
このメールは Google グループのグループ「日本Androidの会」に登録しているユーザーに送られています。
このグループから退会し、グループからのメールの配信を停止するには android-group-j...@googlegroups.com にメールを送信してください。
このグループに投稿するには android-g...@googlegroups.com にメールを送信してください。
http://groups.google.com/group/android-group-japan からこのグループにアクセスしてください。
その他のオプションについては https://groups.google.com/d/optout にアクセスしてください。



--
YAMAZAKI Makoto
Reply all
Reply to author
Forward
0 new messages