Комментарии:
Hey Phillip its a great video. but how to use the check internet flag in our viewModel. do we need to check internet on every api call or any better global way to check?
ОтветитьHow to use it in viewModel where we can't have applicationContext
ОтветитьHi bro you know me who I'm
ОтветитьGood Explanation . Thank you
ОтветитьNetwork status is updated,but what happens when we have wifi connection but not internet.
ОтветитьI believe there is a bug here - if you open the app while network is already available, wouldn't the app still show Unavailable since the initial state you set was UNAVAILABLE and the callback would not actually be triggered for AVAILABLE since it is already available?
I think there needs to be a check for initial state
I tried this implementation to show a toast/snackbar whenever the network connection is lost. It works but the observe function seems to emit duplicate states showing multiple toasts, even with distinctuntilchanged(), I see the same behavior even when converting to a state flow. I fixed this by assigning the send blocks to a job and and canceling the job on each network change call with a delay: ex: override fun onLost(network: Network) {
super.onLost(network)
job?.cancel()
job = launch {
delay(500)
trySend(ConnectivityObserver.Status.Lost)
}
}
Very useful, but what happen with mobile network but not internet data, still get Available
ОтветитьWhat if user has +4G on but got no data plan? What can i do in that case?
Ответитьthis shit.
this code work only when we off wifi and mobile data. when we have bad internet connection this code return avaliable
Should i use sync adapter to synchronize my local db with server?
ОтветитьI've implemented this, but when my internet is off and i'm opening the application, it doesn't trigger disconnected state!!
Can you please give brief!
Thanks
Did you ever handle that last scenario?, A very frequent scenario is when you connect to a public wifi and the network is saturated or internet is down. You will still be connected to the internet, but you wont have any internet access whatsoever.
ОтветитьHey I'm Unable to get the unavailable status im not using compose just observing in activity what am I doing wrong?
ОтветитьNice video.... Thank u so much for this....
ОтветитьThank You for making video in Kotlin 🙏
ОтветитьHow to pass initial state in non-compose application?
ОтветитьHi Philip thanks for this video. I am trying to implement this in my application that uses hilt for DI. I have a custom Interceptor that adds some auth header before the request is being processed, but my application crashes as soon as it opens. How can I catch the error and send it to the user? Thank you
ОтветитьThe observe() function registers a new network callback every time we try to observe it and returns a cold flow. We can prevent this by converting the cold flow into a hot flow using the `shareIn` or `stateIn` operators. We can add a property to the `class NetworkConnectivityObserver` like this:
```
val status: Flow<Status> = observe().stateIn(scope, WhileSubscribed(), Status.Unavailable) // Injected scope
```
Or creating a `class NetworkStatusRepository(CoroutineScope, ConnectivityObserver)` which creates a property like above will be better.
Thank you for your great content, however I seem to get an issue with this - my App doesn't fire when you first hook up the flow and you have no internet - I was expecting it to show 'Unavailable' as it does with 'Available'...
Ответитьhow to observe it without compose collectasstate is not the option available in normal xml
ОтветитьHey, great video, I've tried to implement it but it seems like onUnavailable is not getting triggered? I've tried and turned off wifi and data in emulator, started the app and no log message showed up. Then when I turned on Wifi, Available status got sent to the channel and then when I turned it off, Lost status got sent. But never the Unavailable.
ОтветитьIf I have to ping google to check whether connection really exists or not, how should I do it?
ОтветитьThis is timely. Thanks a lot for the thorough breakdown on how and why.
ОтветитьHi, this crushes app if you turn off and on and turn it back while observing some state.
ОтветитьHi Philipp, thanks for the awesome video, one question, if we were to implement this in ViewModel, we would need to extend AndroidViewModel for getting the application context, is there a way we can do this with extending the simple ViewModel class?
ОтветитьHey bro, Thank you so much for the great content 🙏
One question, can we not use trySend() instead of launch { send( ) }
or is it ultimately the same thing
Thanks
Hi, I have a doubt. For eg: fun getUsers(): Flow<List<ApiUser>> and suspend fun getUsers(): List<ApiUser>. Here both the function will fetch the list of data from the API. What are the benefits of converting API data or List into FLOW? Also, my app does not retrieve streams of data like the stock market or video streaming app. Do I really need to use Flow?
ОтветитьAndroid боклук 😂 Iso iphone 🤘
ОтветитьHey bro I have a question, Have you thought about doing an updated augmented reality course, perhaps with the scene view library on udemy or I don't know if on any platform? Because the scene form is no longer maintained and it is a world with a lot of potential but little explored. Thank you.
ОтветитьWhat's your thought on creating a state based application like implementing FSM(Finite State Machine) in its brother ?
Ответить*Mrs Charlotte is legit and her method works like magic I keep on earning every single week with her new strategies *
ОтветитьThank you sir for the great content, I just want to know where does the observer fit in the clean architecture design
ОтветитьPhillip i was finding a solution like this, thanks brother.
ОтветитьAwesome tutorial Phill
ОтветитьI try these code but these callback is not work(apart from onAvailable)..
ОтветитьVery nice. Exactly what I needed right now 😂
ОтветитьVERY COOL
YOU ARE THE BEST
Wouldn't it be better to use StateFlow, less and cleaner code?
ОтветитьIt's a useful demo for handling the context depend resource by callbackflow ❤️
ОтветитьConnectivity means nothing, if it is connected not the fact user have internet
Ответитьplease tell me how to create game animation
please tell me about graphics
canvas unity, agdk
Great tutorial! I would love to have a video which will expand this knowledge to Ethernet connection observer via broadcast receiver for Android boxes!
ОтветитьMuch needed 💙
ОтветитьI am having an Issue to when I add the Permissions for the Network_State. it Informs me even after adding to manifest permission is still missing
Ответить