小编Ade*_*har的帖子

仅当应用程序在 android pie 中关闭时,广播接收器才不起作用

我每次都使用Broadcast Receiver触发incoming messages。它在Android O任一应用程序中的工作正常是否关闭。但Android P它仅在应用程序处于活动状态和应用程序关闭时才有效。无论应用程序是关闭还是不在Android P. 我遵循了这个链接和许多其他链接,但问题仍然存在。

清单中的接收者注册

<receiver
            android:name=".Broadcast.SmsListener"
            android:enabled="true"
            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.intent.action.BOOT_COMPLETED" />
            </intent-filter>
        </receiver>
Run Code Online (Sandbox Code Playgroud)

广播接收器类

    public class SmsListener extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        Log.d("Resulted12", "Into onReceive()");
        context.startService(new Intent(context, BackgroundService.class));
    }
}
Run Code Online (Sandbox Code Playgroud)

还有什么我错过的吗?

android background broadcastreceiver

8
推荐指数
1
解决办法
1750
查看次数

构建React Native项目时出错

我收到了以下错误

FAILURE:构建因异常而失败.

* Where:
Settings file 'G:\ReactNative\Contacts\android\settings.gradle' line: 3

    * What went wrong:
    Could not compile settings file 'G:\ReactNative\Contacts\android\settings.gradle'.
    > startup failed:
      settings file 'G:\ReactNative\Contacts\android\settings.gradle': 3: unexpected char: '\' @ line 3, column 133.
         s\react-native-gesture-handler\android')
Run Code Online (Sandbox Code Playgroud)

settings.gradle

rootProject.name = 'Contacts'
include ':react-native-gesture-handler'
project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '..\node_modules\react-native-gesture-handler\android')
include ':react-native-vector-icons'
project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '..\node_modules\react-native-vector-icons\android')

include ':app'
Run Code Online (Sandbox Code Playgroud)

这个文件实际上有什么问题?

android-gradle-plugin react-native

6
推荐指数
1
解决办法
1984
查看次数