0

我有一个BroadcastReceiver在清单中注册的应用程序

    <receiver
        android:name=".smsprocessing.SmsBroadcastReceiver"
        android:exported="true"
        android:permission="android.permission.BROADCAST_SMS">
        <intent-filter android:priority="999">
            <action android:name="android.provider.Telephony.SMS_RECEIVED" />
            <action android:name="android.provider.Telephony.SMS_DELIVER" />
            <action android:name="android.provider.Telephony.SMS_DELIVER_ACTION" />
            <action android:name="android.intent.action.BOOT_COMPLETED" />
        </intent-filter>
    </receiver>

当我测试它时它一直工作得很好,但今天我尝试向安装了我几个小时没有碰过的应用程序的手机发送短信。该应用程序在测试之前在这款手机上运行良好,但我总是在显示屏打开或锁定屏幕后几分钟内对其进行测试。

BroadcastReceiver当我几个小时没有使用手机时,似乎我今天没有被触发。收到短信并触发了股票消息应用程序,但我的 BroadcastReceiver 没有被触发(或者至少,我开始的前台服务onReceive()没有启动)。

有问题的手机是运行 Android 4.4.4 的摩托罗拉 Moto G。

编辑

当我在应该触发广播接收器几分钟后通过 USB 连接手机时,我只看到两个与我的应用程序相关的日志:

10-12 22:33:28.438 1039-1053/? I/ActivityManager: Start proc com.example.myapp for broadcast com.example.myapp/com.example.myapp.smsprocessing.SmsBroadcastReceiver: pid=3554 uid=10230 gids={50230, 3003}
10-12 22:33:28.961 1039-4323/? I/ActivityManager: Process com.example.myapp (pid 3554) has died.

这是(我认为)收到短信时的完整日志(我在上面的两行前面加上了###):

10-12 22:33:28.235 1039-1186/? I/PackageManager: Adding preferred activity ComponentInfo{com.android.mms/com.android.mms.ui.ComposeMessageActivity} for user 0 :
10-12 22:33:28.271 1039-4323/? I/PackageManager: Adding preferred activity ComponentInfo{com.android.mms/com.android.mms.ui.ComposeMessageActivity} for user 0 :
10-12 22:33:28.291 1039-1401/? I/PackageManager: Adding preferred activity ComponentInfo{com.android.mms/com.android.mms.ui.ComposeMessageActivity} for user 0 :
10-12 22:33:28.312 1039-1100/? I/PackageManager: Adding preferred activity ComponentInfo{com.android.mms/com.android.mms.ui.ComposeMessageActivity} for user 0 :
10-12 22:33:28.345 1039-1053/? I/ActivityManager: Start proc com.android.mms for broadcast com.android.mms/.transaction.PrivilegedSmsReceiver: pid=3524 uid=10030 gids={50030, 3003, 1028, 1015}10-12 22:33:28.345 1039-1053/? I/ActivityManager: Start proc com.android.mms for broadcast com.android.mms/.transaction.PrivilegedSmsReceiver: pid=3524 uid=10030 gids={50030, 3003, 1028, 1015}
### 10-12 22:33:28.438 1039-1053/? I/ActivityManager: Start proc com.example.myapp for broadcast com.example.myapp/com.example.myapp.smsprocessing.SmsBroadcastReceiver: pid=3554 uid=10230 gids={50230, 3003}
10-12 22:33:28.635 1039-1093/? D/WifiService: Client connection lost with reason: 4
10-12 22:33:28.644 1039-1050/? I/ActivityManager: Start proc android.process.acore for content provider com.android.providers.contacts/.ContactsProvider2: pid=3571 uid=10010 gids={50010, 3003, 1028, 1015, 1023}
10-12 22:33:28.645 1039-4321/? I/ActivityManager: Process com.google.android.gms (pid 2593) has died.
10-12 22:33:28.648 1039-4321/? W/ActivityManager: Service ServiceRecord{43d5d0e0 u0 com.google.android.gms/.chimera.GmsApiService} in process ProcessRecord{425f9028 2593:com.google.android.gms/u0a22} not same as in map: null
10-12 22:33:28.649 1039-4321/? W/ActivityManager: Scheduling restart of crashed service com.google.android.gms/.chimera.GmsIntentOperationService in 26259ms
    Scheduling restart of crashed service com.google.android.gms/.checkin.CheckinService in 26259ms
    Service ServiceRecord{43116f88 u0 com.google.android.gms/.chimera.GmsBoundBrokerService} in process ProcessRecord{425f9028 2593:com.google.android.gms/u0a22} not same as in map: null
10-12 22:33:28.848 1039-1290/? I/ActivityManager: Start proc com.google.android.gms for service com.google.android.gms/.ads.identifier.service.AdvertisingIdService: pid=3618 uid=10022 gids={50022, 3003, 1007, 1028, 1015, 3002, 3001, 3007, 2001, 3006}
### 10-12 22:33:28.961 1039-4323/? I/ActivityManager: Process com.example.myapp (pid 3554) has died.
10-12 22:33:29.279 1039-1313/? I/ActivityManager: Process com.google.android.apps.photos (pid 3476) has died.
10-12 22:33:29.998 1039-1049/? I/ActivityManager: Process com.google.android.gms.unstable (pid 3285) has died.
10-12 22:33:30.227 1039-1093/? D/WifiService: New client listening to asynchronous messages
10-12 22:33:30.422 263-349/? W/Vold: Returning OperationFailed - no handler for errno 30
10-12 22:33:30.425 263-349/? W/Vold: Returning OperationFailed - no handler for errno 30
10-12 22:33:30.483 1039-1100/? I/ActivityManager: Start proc com.google.android.gms.unstable for service com.google.android.gms/.droidguard.DroidGuardService: pid=3693 uid=10022 gids={50022, 3003, 1007, 1028, 1015, 3002, 3001, 3007, 2001, 3006}
10-12 22:33:30.847 1039-4323/? I/ActivityManager: Process android.process.acore (pid 3571) has died.
10-12 22:33:31.308 1039-3556/? I/ActivityManager: Process com.android.mms (pid 3524) has died.
4

0 回答 0