Skip to content

Instantly share code, notes, and snippets.

final class ConnectivityStateManager {
...
private volatile ConnectivityState state = ConnectivityState.IDLE;
...
}
public final class ManagedChannelImplBuilder extends ManagedChannelBuilder<ManagedChannelImplBuilder> {
...
static final long IDLE_MODE_DEFAULT_TIMEOUT_MILLIS = TimeUnit.MINUTES.toMillis(30);
static final long IDLE_MODE_MIN_TIMEOUT_MILLIS = TimeUnit.SECONDS.toMillis(1);
...
}
val channel = AndroidChannelBuilder
.forAddress("127.0.0.1", 9090)
.context(androidContext)
.build()
val channel = AndroidChannelBuilder
.forAddress("127.0.0.1", 9090)
.maxRetryAttempts(10)
.build()
val channelWithKeepAlive = AndroidChannelBuilder
.forAddress("127.0.0.1", 9090)
.keepAliveTime(20, TimeUnit.SECONDS)
.keepAliveTimeout(5, TimeUnit.SECONDS)
.build()
syntax = "proto3";
package com.victorbrandalise;
service Bookstore {
rpc CreateBook(CreateBookRequest) returns (Book) {}
rpc ListBooks(ListBooksRequest) returns (ListBooksResponse) {}
}
message Book {
val scope = CoroutineScope(Dispatchers.IO)
fun main() {
val channel = AndroidChannelBuilder
.forAddress("127.0.0.1", 9090)
.build()
val book = BookOuterClass.Book.newBuilder()
.setId(1)
.setTitle("gRPC In-Depth")
private const val CHANNEL_ID = "heads_up_alerts"
private const val CHANNEL_NAME = "Heads Up Alerts"
private val notificationManager = NotificationManagerCompat.from(context)
private fun createNotificationChannel() {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) return
val channel = NotificationChannel(
CHANNEL_ID, CHANNEL_NAME, NotificationManager.IMPORTANCE_HIGH
const val NOTIFICATION_ID = 24756
notificationManager.notify(NOTIFICATION_ID, createNotification())
class HomeActivity : AppCompatActivity() {
private lateinit var binding: ActivityHomeBinding
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityHomeBinding.inflate(layoutInflater)
setContentView(binding.root)
}