我有一个应用程序,在AndroidManifest.xml
中定义了一个Receiver,它似乎随机被禁用,导致应用程序强行关闭,直到重新安装该应用程序。在此之前,应用程序可能会在一天,一周或一个月内正常工作。
adb shell dumpsys
的相关输出:
Package [com.example.helloworld.debug] (34181cc):
userId=10196 gids=[3003, 1028, 1015, 3002, 3001]
pkg=Package{388362dc com.example.helloworld.debug}
codePath=/data/app/com.example.helloworld.debug-1
resourcePath=/data/app/com.example.helloworld.debug-1
legacyNativeLibraryDir=/data/app/com.example.helloworld.debug-1/lib
primaryCpuAbi=null
secondaryCpuAbi=null
versionCode=1 targetSdk=22
versionName=1.0d
splits=[base]
applicationInfo=ApplicationInfo{2a384fe5 com.example.helloworld.debug}
flags=[ DEBUGGABLE HAS_CODE ALLOW_CLEAR_USER_DATA VM_SAFE_MODE ALLOW_BACKUP ]
dataDir=/data/data/com.example.helloworld.debug
supportsScreens=[small, medium, large, xlarge, resizeable, anyDensity]
timeStamp=2015-06-02 13:42:27
firstInstallTime=2015-06-02 13:42:27
lastUpdateTime=2015-06-02 13:42:27
signatures=PackageSignatures{126ffaba [1dee9d6b]}
permissionsFixed=true haveGids=true installStatus=1
pkgFlags=[ DEBUGGABLE HAS_CODE ALLOW_CLEAR_USER_DATA VM_SAFE_MODE ALLOW_BACKUP ]
User 0: installed=true hidden=false stopped=false notLaunched=false enabled=0
disabledComponents:
com.et.sdk.ETLocationReceiver
grantedPermissions:
com.example.helloworld.debug.permission.C2D_MESSAGE
com.google.android.c2dm.permission.RECEIVE
android.permission.ACCESS_FINE_LOCATION
android.permission.RECEIVE_BOOT_COMPLETED
android.permission.BLUETOOTH
android.permission.INTERNET
android.permission.BLUETOOTH_ADMIN
android.permission.READ_EXTERNAL_STORAGE
android.permission.ACCESS_COARSE_LOCATION
android.permission.ACCESS_NETWORK_STATE
android.permission.DISABLE_KEYGUARD
android.permission.GET_ACCOUNTS
android.permission.WRITE_EXTERNAL_STORAGE
android.permission.VIBRATE
android.permission.ACCESS_WIFI_STATE
android.permission.WAKE_LOCK
AndroidManifest.xml
的相关部分:
<!-- ETLocationReceiver and Service -->
<receiver android:name="com.et.sdk.ETLocationReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.BATTERY_LOW" />
<action android:name="android.intent.action.BATTERY_OKAY" />
</intent-filter>
<intent-filter>
<action android:name="android.location.PROVIDERS_CHANGED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</receiver>
可以在GitHub上找到完整的来源https://github.com/androidfu/EtPushHelloWorld
答案 0 :(得分:1)
经过进一步审核后发现BATTERY_LOW条件禁用了LocationReceiver。感谢@CommonsWare提示让我继续挖掘。