简体   繁体   English

android事物中的bindservice manifest.xml选项ACTION_BOOT_COMPLETED

[英]bindservice in android things manifest.xml option ACTION_BOOT_COMPLETED

I have this project https://github.com/neuberfran/SmartDrive5 The issue is: the application (according to logcat) never passes in: Log.i(TAG, "Volto 101.00 ${teste}") in ModoAutomatico.kt File and in Log.i(ContentValues.TAG, "Volto 106.00") In DriverService.kt file 我有这个项目https://github.com/neuberfran/SmartDrive5的问题是:在ModoAutomatico.kt文件Log.i(TAG,“VOLTO 101.00 $ {}泰斯特”):应用程序(根据logcat的)从来没有在传递并在DriverService.kt文件中的Log.i(ContentValues.TAG,“ Volto 106.00”)中

When I put application android:name="com.you.yourapp.ApplicationEx" in Manifest.xml I have new issue: ***Service Intent must be explicit: Intent { }*** 当我在Manifest.xml放置应用程序android:name="com.you.yourapp.ApplicationEx" ,我遇到了新问题: ***Service Intent must be explicit: Intent { }***

在此处输入图片说明

How can I implement bindservice in this android things applications? 如何在此Android Things应用程序中实现bindservice?

Android Things doesn't have any special requirements when it comes to binding services. 对于绑定服务,Android Things没有任何特殊要求。

I have this project https://github.com/neuberfran/SmartDrive5 我有这个项目https://github.com/neuberfran/SmartDrive5

The code that you are using to bind to the service in your GitHub project is incorrect. 您用于绑定到GitHub项目中的服务的代码不正确。 The ComponentName constructor requires the package name of your app (not the package of the class), so your should look like this: ComponentName构造函数需要您的应用程序的程序包名称(而不是类的程序包),因此您应如下所示:

val driverService = ComponentName(
        "com.example.neube.smartdrive",
        "com.example.neube.smartdrive.controlamotores.modooffline.DriverService"
)

val serviceIntent = Intent()
serviceIntent.component = driverService

// Bind to the driver service
bindService(serviceIntent, callback, BIND_AUTO_CREATE)

Note this format is really only necessary if you are calling a service in a remote process. 请注意,只有在远程过程中调用服务时,才真正需要这种格式。 Since you are binding to a service from within the same app context, it's much more straightforward to construct the intent this way: 由于您是从同一应用程序上下文中绑定到服务,因此以这种方式构造意图要简单得多:

val serviceIntent = Intent(this, DriverService::class.java)
// Bind to the driver service
bindService(serviceIntent, callback, BIND_AUTO_CREATE)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM