diff --git a/SensorsAnalyticsSDK/SensorsAnalyticsSDK/build.gradle b/SensorsAnalyticsSDK/SensorsAnalyticsSDK/build.gradle index 7f2f84a9..e678c72a 100644 --- a/SensorsAnalyticsSDK/SensorsAnalyticsSDK/build.gradle +++ b/SensorsAnalyticsSDK/SensorsAnalyticsSDK/build.gradle @@ -3,7 +3,7 @@ apply plugin: 'com.android.library' apply plugin: 'com.github.dcendents.android-maven' apply plugin: 'com.jfrog.bintray' -version = "1.6.36" +version = "1.6.37" android { compileSdkVersion 21 diff --git a/SensorsAnalyticsSDK/SensorsAnalyticsSDK/src/main/java/com/sensorsdata/analytics/android/sdk/AnalyticsMessages.java b/SensorsAnalyticsSDK/SensorsAnalyticsSDK/src/main/java/com/sensorsdata/analytics/android/sdk/AnalyticsMessages.java index 913599aa..d6c165ab 100644 --- a/SensorsAnalyticsSDK/SensorsAnalyticsSDK/src/main/java/com/sensorsdata/analytics/android/sdk/AnalyticsMessages.java +++ b/SensorsAnalyticsSDK/SensorsAnalyticsSDK/src/main/java/com/sensorsdata/analytics/android/sdk/AnalyticsMessages.java @@ -88,11 +88,11 @@ public void enqueueEventMessage(final String type, final JSONObject eventJson) { final Message m = Message.obtain(); m.what = FLUSH_QUEUE; - if (SensorsDataAPI.sharedInstance(mContext).isDebugMode() || ret == - DbAdapter.DB_OUT_OF_MEMORY_ERROR) { - mWorker.runMessage(m); - } else { - if (SensorsDataUtils.isNetworkAvailable(mContext)) { + if (SensorsDataUtils.isNetworkAvailable(mContext)) { + if (SensorsDataAPI.sharedInstance(mContext).isDebugMode() || ret == + DbAdapter.DB_OUT_OF_MEMORY_ERROR) { + mWorker.runMessage(m); + } else { // track_signup 立即发送 if (type.equals("track_signup") || ret > SensorsDataAPI.sharedInstance(mContext) .getFlushBulkSize()) { diff --git a/SensorsAnalyticsSDK/SensorsAnalyticsSDK/src/main/java/com/sensorsdata/analytics/android/sdk/SensorsDataAPI.java b/SensorsAnalyticsSDK/SensorsAnalyticsSDK/src/main/java/com/sensorsdata/analytics/android/sdk/SensorsDataAPI.java index c9de27db..3352e162 100644 --- a/SensorsAnalyticsSDK/SensorsAnalyticsSDK/src/main/java/com/sensorsdata/analytics/android/sdk/SensorsDataAPI.java +++ b/SensorsAnalyticsSDK/SensorsAnalyticsSDK/src/main/java/com/sensorsdata/analytics/android/sdk/SensorsDataAPI.java @@ -15,11 +15,8 @@ import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.net.Uri; -import android.net.wifi.WifiInfo; -import android.net.wifi.WifiManager; import android.os.Build; import android.os.Bundle; -import android.provider.Settings; import android.telephony.TelephonyManager; import android.text.TextUtils; import android.util.DisplayMetrics; @@ -229,6 +226,11 @@ boolean isDebugWriteData() { deviceInfo.put("$carrier", "其他"); } } + +// String androidID = SensorsDataUtils.getAndroidID(mContext); +// if (!TextUtils.isEmpty(androidID)) { +// deviceInfo.put("$device_id", androidID); +// } } mDeviceInfo = Collections.unmodifiableMap(deviceInfo); @@ -1373,6 +1375,12 @@ public void onActivityStarted(Activity activity) { mFirstStart.commit(false); } + try { + appBecomeActive(); + } catch (Exception e) { + e.printStackTrace(); + } + if (mAutoTrack) { try { JSONObject properties = new JSONObject(); @@ -1462,6 +1470,12 @@ public void onActivityStopped(Activity activity) { startedActivityCount = startedActivityCount - 1; if (startedActivityCount == 0) { + try { + appEnterBackground(); + } catch (Exception e) { + e.printStackTrace(); + } + if (mAutoTrack) { try { track("$AppEnd"); @@ -1681,7 +1695,7 @@ private static void mergeJSONObject(final JSONObject source, JSONObject dest) static final int VTRACK_SUPPORTED_MIN_API = 16; // SDK版本 - static final String VERSION = "1.6.36"; + static final String VERSION = "1.6.37"; static Boolean ENABLE_LOG = false; diff --git a/SensorsAnalyticsSDK/SensorsAnalyticsSDK/src/main/java/com/sensorsdata/analytics/android/sdk/ViewCrawler.java b/SensorsAnalyticsSDK/SensorsAnalyticsSDK/src/main/java/com/sensorsdata/analytics/android/sdk/ViewCrawler.java index a694eeb1..e7cc10e3 100644 --- a/SensorsAnalyticsSDK/SensorsAnalyticsSDK/src/main/java/com/sensorsdata/analytics/android/sdk/ViewCrawler.java +++ b/SensorsAnalyticsSDK/SensorsAnalyticsSDK/src/main/java/com/sensorsdata/analytics/android/sdk/ViewCrawler.java @@ -199,10 +199,6 @@ public void onActivityResumed(Activity activity) { mStartedActivities.add(activity); - if (mStartedActivities.size() == 1) { - SensorsDataAPI.sharedInstance(mContext).appBecomeActive(); - } - for (String className : mDisabledActivity) { if (className.equals(activity.getClass().getCanonicalName())) { return; @@ -223,9 +219,7 @@ public void onActivityPaused(Activity activity) { @Override public void onActivityStopped(Activity activity) { - if (mStartedActivities.size() == 0) { - SensorsDataAPI.sharedInstance(mContext).appEnterBackground(); - } + } @Override