[英]Android BroadcastReceiver not working when app is installed from play store
I have a service that is getting battery updates via Intent.ACTION_BATTERY_CHANGED: 我有一项通过Intent.ACTION_BATTERY_CHANGED获取电池更新的服务:
batteryFilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
batteryReceiver = new BatteryReceiver();
and the receiver: 和接收者:
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if(action.equals(Intent.ACTION_POWER_CONNECTED)) {
onBattery = false;
Log.w("battery","on power");
}
else if(action.equals(Intent.ACTION_POWER_DISCONNECTED)) {
Log.w("battery","on battery");
onBattery = true;
}
}
This works exactly as expected when the app is installed via USB debugging. 当通过USB调试安装应用程序时,这与预期完全一致。 After I published this to the play store and did a fresh install from there, it doesn't work. 在我将它发布到游戏商店并从那里进行全新安装后,它不起作用。 Other receivers aren't working in the app either. 其他接收器也没有在应用程序中工作。 The rest of the app appears to be working properly, just no broadcast receivers are working. 应用程序的其余部分似乎工作正常,没有广播接收器工作。 What could cause this to happen? 什么可能导致这种情况发生?
This is android 2.2 and it is an update to an app that was already in the store, the receiver was working properly before the update also. 这是android 2.2,它是对已经在商店中的应用程序的更新,接收器在更新之前也正常工作。
如果您在Android 3.1+上运行,并且您没有手动运行其中一个组件(例如,从启动器启动活动),则您的所有清单注册的BroadcastReceiver
都不会起作用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.