我在我的一个 Android 应用程序上遇到大量电池消耗,我相信这是由于 GPS 已打开,但在新活动开始时从未关闭。我正在使用从其他人那里继承的代码库。如果您有解决此问题的方法,请告诉我。
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Start the tracker in manual dispatch mode...
GoogleAnalyticsTracker.getInstance().startNewSession(sessionCode, this);
//Get url to get survey and tags
urlSurveyFilter = Global.getInstance().getUrlStringForRequest(R.string.jsonsurveys, this);
urlJsonTag = Global.getInstance().getUrlStringForRequest(R.string.jsontagrequest,this);
//to use the KinseyAppActivity.this like a global variable
_this = this;
//set the layout from my xml
setContentView(R.layout.main1);
Global.getInstance().locatePosition(MapViewActivity.this);
// button to choice the filter
Button filterButton = (Button) findViewById(R.id.filterButton);
filterButton.setOnClickListener(new View.OnClickListener() {
@SuppressWarnings("deprecation")
@Override
public void onClick(View v) {
sendTrackingEvents("Click Filter Button", "Open the filter", "clicked", 1, "/MapActivity");
showDialog(0);
}
});