由网友(南笙浅梦墨汐°)分享简介:我只是想获得的时间用于每项活动的号码。所以很简单的方法,我认为是增加了计数的活动它启动时。但是,我怎么能得到这些信息?I just want to get numbers of times to be used for each Activity.So the very straightforward metho...
我只是想获得的时间用于每项活动的号码。 所以很简单的方法,我认为是增加了计数的活动它启动时。但是,我怎么能得到这些信息?
I just want to get numbers of times to be used for each Activity. So the very straightforward method I thought is increasing the count for an Activity when it was started. But how can I get the information?
感谢您的帮助很大!
推荐答案
最后,我找到了一个解决方案,使用IActivityWatcher和ActivityManagerNative,并建立在源$ C $ C。
Finally, I found a solution, use IActivityWatcher and ActivityManagerNative, and build in source code.
感谢T3Roar非常多,我只是按照你的线索,找到这一点。
Thank T3Roar very much, I just follow your clue to find this.
下面的示例code:
package zouyu.sample.activitymonitor;
import android.app.Activity;
import android.app.ActivityManagerNative;
import android.app.IActivityWatcher;
import android.os.Bundle;
import android.os.RemoteException;
import android.util.Log;
public class ActivityMonitor extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
try {
ActivityManagerNative.getDefault().registerActivityWatcher(mActivityWatcher);
} catch (RemoteException e) {
}
}
private IActivityWatcher.Stub mActivityWatcher = new IActivityWatcher.Stub() {
public void activityResuming(int activityId) throws RemoteException {
Log.e("zouyu", "In ActivityMonitor, an Activity resuming: " + activityId);
}
public void closingSystemDialogs(String reason) {
Log.e("zouyu", "In ActivityMonitor, an Activity closing: " + reason);
}
};
}
相关推荐
最新文章