简体   繁体   English

从Play商店安装应用程序时,Android BroadcastReceiver无法正常工作

[英]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.

相关问题 Android:安装APK后从Play商店重定向到Android应用 - Android: Redirect to android app from play store when apk is installed 在SD卡上安装了应用程序后,BroadcastReceiver无法正常工作 - BroadcastReceiver not working when app is installed on sd card Android DJI SDK - 我从 Play 商店安装的 App Bundle 挂起一个完美运行的应用程序 - Android DJI SDK - My App Bundle installed from Play Store hangs an otherwise perfectly working app 通过单击浏览器或邮件应用程序中的链接,在Android中未安装应用程序时打开Play商店 - open play store when app not installed in android by clicking the link from browser or mail App 从 Play 商店安装应用程序时,flutter firebase 手机身份验证不起作用 - flutter firebase phone authentication not working when the app is installed from play store 深层链接 - 从 Play 商店安装应用时获取数据 - Deep linking - Fetch data when app installed from play store 从 Google Play 商店安装应用程序时崩溃 - App is crashing when installed from Google Play store 应用被杀死时,Android BroadcastReceiver无法正常工作 - Android BroadcastReceiver Not Working When App Killed 还安装了来自 Play 商店的应用时,由于冲突而未安装应用 - App not installed due to conflict when app from play store is also installed 使用 Android Studio Android 应用程序在设备上运行 Google plus 但从 Play 商店下载时不起作用 - Using Android Studio Android app Working Google plus on device but when downloaded from play store Not Work
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM