我在 nodejs 中创建了一个 gRPC 服务器(由 AWS 托管),我可以使用本地机器上的 nodejs 客户端实现连接到它。
我正在使用该com.google.protobuf插件从我的.proto文件中自动生成代码。我的 gradle 同步工作正常,应用程序构建成功,但我找不到生成的代码类。我正在努力为 Android gRPC 客户端的 Kotlin 寻找一个好的实现示例,但我遵循了以下文章:
我的app/src/main/protos/responder.proto档案
syntax = "proto3";
option java_package = "protos.grpc";
package responder;
message ConnectionRequest {
int32 userId = 2;
}
message ConnectionResponse {
string response = 1;
}
service ResponderService {
rpc responderConnect (stream ConnectionRequest) returns (stream ConnectionResponse) {};
}
Run Code Online (Sandbox Code Playgroud)
项目 build.gradle
// Top-level build file where you can add configuration options common to all …Run Code Online (Sandbox Code Playgroud) 我正在使用 JS 框架创建一个 HarmonyOS 可穿戴应用程序,我想使用振动器。手表肯定有一个振动器,因为当我在设置应用程序中使用滚动条时我能感觉到它。
所以,我要求system_grantohos.permission.VIBRATE中许可config.json文件所描述的在这里
"module": {
...
"reqPermissions": [
{
"name": "ohos.permission.VIBRATE",
"reason": "Make vibrates"
}
]
...
}
Run Code Online (Sandbox Code Playgroud)
那么像这样使用进口的振动器应该很简单
import vibrator from '@system.vibrator';
export default {
// ...
onShow() {
console.log("VIBRATOR");
vibrator.vibrate({
mode : "long",
success: () => console.debug("Vibrator Success"),
fail : (data, code) => console.log("Vibrator handle fail, data = ${data}, code = ${code}"),
complete : () => console.debug("Vibrator Complete")
});
}
// ...
}
Run Code Online (Sandbox Code Playgroud)
我确实VIBRATOR登录了,HiLog但振动器回调中的其他日志没有,设备也没有振动。
有谁知道我做错了什么?
编辑:我注意到日志后有一堆错误 …
我正在尝试从一个导航图(主机片段位于LoginActivity)导航到另一个导航图(主机片段位于HomeActivity)。我知道谷歌提倡使用单一活动应用程序,因此我只会使用这两个活动(以保持最少)。
我的 login_navigation.xml
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/mobile_navigation"
app:startDestination="@id/nav_login">
<fragment
android:id="@+id/nav_login"
android:name="your.appname.LoginFragment"
android:label="@string/login_menu"
tools:layout="@layout/fragment_login" >
<action
android:id="@+id/action_nav_login_to_enterCellphone"
app:destination="@id/login_enter_cellphone"
app:popUpTo="@id/nav_login" />
</fragment>
<fragment
android:id="@+id/login_enter_cellphone"
android:name="your.appname.LoginEnterCellphoneFragment"
android:label="@string/enter_cellphone_fragment_label"
tools:layout="@layout/fragment_login_enter_cellphone" >
<action
android:id="@+id/action_enter_cellphone_to_enterOTPFragment"
app:destination="@id/enterOTPFragment"
app:popUpTo="@id/login_enter_cellphone" />
</fragment>
<fragment
android:id="@+id/enterOTPFragment"
android:name="your.appname.EnterOTPFragment"
android:label="@string/enter_otp_label"
tools:layout="@layout/fragment_enter_o_t_p" >
<action
android:id="@+id/action_enterOTPFragment_to_main_navigation"
app:destination="@id/main_navigation"
app:launchSingleTop="false" />
</fragment>
<include app:graph="@navigation/main_navigation" />
</navigation>
Run Code Online (Sandbox Code Playgroud)
和 main_navigation.xml
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_navigation"
app:startDestination="@id/nav_home">
<fragment
android:id="@+id/nav_home"
android:name="your.appname.HomeFragment"
android:label="Home"
tools:layout="@layout/fragment_home" />
<fragment
android:id="@+id/nav_profile"
android:name="your.appname.ProfileFragment"
android:label="@string/profile_menu"
tools:layout="@layout/fragment_profile" />
</navigation> …Run Code Online (Sandbox Code Playgroud) navigation android kotlin android-architecture-navigation android-jetpack-navigation
android ×2
kotlin ×2
android-architecture-navigation ×1
gradle ×1
grpc ×1
harmonyos ×1
navigation ×1
wearables ×1