0

この情報を使用して、デバイスで最も頻繁に使用されるアプリを特定したいと考えています。

また、自分のデバイスで各アプリを使用した時間を特定する方法があるかどうかも知りたいと思っています。

この情報は、「ジェイルブレイクされた」デバイスでのみアクセスできるようです。そうではないことを願っています。

どうもありがとう!

4

1 に答える 1

0

すべてのアプリでそれを行うことはできないと思います。

代わりに、アプリが起動された回数を知りたい場合は、これを試してください。

アプリのスプラッシュスクリーン (または起動された最初のアクティビティ) で、数値を増やしてみて、次の場所に保存しますSharedPreferences

SharedPreferences prefs = getSharedPreferences("prefs",Context.MODE_PRIVATE);
int counter = prefs.getInt("counter", -1);

if(counter == -1 ) {
   //first launch of the app, init the counter 
   counter = 1;
}
else {
  // increment the counter
  counter++;
}

// update the value of the counter 
SharedPreferences.Editor editor = prefs.edit();
editor.putInt("counter",counter);
editor.commit();

//then you can do what you want with your counter , send it to your back end via web service...etc 
于 2012-11-28T16:22:19.223 に答える