-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prefer wifi network when connecting over udp #109
Conversation
if ( networkInfo.getType() == ConnectivityManager.TYPE_WIFI ) { | ||
cm.bindProcessToNetwork( net ); | ||
} | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The break should be inside the if statement, otherwise only the first network is evaluated, which might be the mobile network.
With that change it works perfectly for me!
Thx for the comment. I will fix it.
…On Thu, Aug 22, 2019, 14:31 Kevin ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In
Android/ChorusRFLaptimer/app/src/main/java/app/andrey_voroshkov/chorus_laptimer/MainActivity.java
<#109 (comment)>
:
> @@ -243,8 +247,22 @@ public void handleMessage(Message msg) {
startActivityForResult(intent, BluetoothState.REQUEST_CONNECT_DEVICE);
break;
case R.id.menuUDPConnect:
+ ConnectivityManager cm = (ConnectivityManager) getSystemService( Context.CONNECTIVITY_SERVICE );
+ if ( Build.VERSION.SDK_INT >= Build.VERSION_CODES.M ) {
+ for ( Network net : cm.getAllNetworks() ) {
+ NetworkInfo networkInfo = cm.getNetworkInfo( net );
+ if ( networkInfo.getType() == ConnectivityManager.TYPE_WIFI ) {
+ cm.bindProcessToNetwork( net );
+ }
+ break;
The break should be inside the if statement, otherwise only the first
network is evaluated, which might be the mobile network.
With that change it works perfectly for me!
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#109?email_source=notifications&email_token=AAD3IBLHUKVYTCSQJETNDETQFZ2I3A5CNFSM4IKCQ5E2YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCCLVZNY#pullrequestreview-278355127>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAD3IBJZVJELXYBZAK5KDATQFZ2I3ANCNFSM4IKCQ5EQ>
.
|
This works for android 6 and above
Fixed the issue above and extracted a method to make the code a bit easier to understand |
@voroshkov Do you want me to change anything still or expand the prefering of WIFI to TCP also? |
@Nisse43, oops, sorry, lost a sense of time after the flying season. Will take a look at PRs soon. Thanks for reminding! |
This works for android M 26 and above
This fixes issue #81