fix (when initailly there is no internet connection)#4
Open
milon27 wants to merge 1 commit intomitchtabian:masterfrom
Open
fix (when initailly there is no internet connection)#4milon27 wants to merge 1 commit intomitchtabian:masterfrom
milon27 wants to merge 1 commit intomitchtabian:masterfrom
Conversation
when you have an internet connection and you launch the app. it's showing connected with the internet. but when you turn off all networks and lanch the app again it's showing noting. the network callback did not trigger at all until you again turn on the wifi/internet. fix this issue.
Owner
|
What device/version are you testing on? I cannot reproduce with API 30 pixel XL |
Author
|
Pixel_4a_API_30 |
Owner
|
I'm unable to reproduce with that exact device. I don't know what to tell you. |
Author
|
If you don't have internet connection and launch the app first time do you have that no internet connection banner? |
Owner
|
Yes
…On Wed., Jul. 7, 2021, 2:56 p.m. Md Jahidul Islam, ***@***.***> wrote:
If you don't have internet connection and launch the app first time do you
have that no internet connection banner?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#4 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AEFDMUDUD7XRLJC75RN5TFDTWTEQ5ANCNFSM477NW3EQ>
.
|
Author
|
Its confusing. I don't know why this is happening with some of us. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
when you have an internet connection and you launch the app. it's showing connected with the internet.
but when you turn off all networks and lanch the app again it's showing noting. the network callback did not trigger at all until you again turn on the wifi/internet.
fix this issue.
override fun onActive() { networkCallback = createNetworkCallback() val networkRequest = NetworkRequest.Builder() .addCapability(NET_CAPABILITY_INTERNET) .addTransportType(NetworkCapabilities.TRANSPORT_WIFI) .addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR) .build() + val ckInitialNet = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { + cm.getNetworkCapabilities(cm.activeNetwork) + ?.hasCapability(NET_CAPABILITY_INTERNET)==true + } else { + val net=cm.allNetworks.find { + cm.getNetworkCapabilities(it)?.hasCapability(NET_CAPABILITY_INTERNET)==true + } + cm.getNetworkCapabilities(net) + ?.hasCapability(NET_CAPABILITY_INTERNET)==true + } + if(!ckInitialNet){ + //initially there is no internet connection. + postValue(false) + } cm.registerNetworkCallback(networkRequest, networkCallback) }