-1
ConnectionQuality
の回答を得なければならないFast Networking Library
を使用していますが、回答は常にConnectionQuality.UNKNOWN
でresponse
になります。私はFast Networking Libraryを使用しています。 以下は私のコードです。 AndroidのフレームワークとしてAndroid Fast Networkingライブラリの高速ネットワークライブラリでConnectionQualityが機能していません
public class MainActivity extends AppCompatActivity implements View.OnClickListener {
private Button btnNetworkQuality;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
setIds();
setListner();
}
private void setIds() {
try {
btnNetworkQuality = (Button) findViewById(R.id.btnNetworkQuality);
} catch (Exception e) {
e.printStackTrace();
}
}
private void setListner() {
try {
btnNetworkQuality.setOnClickListener(this);
} catch (Exception e) {
e.printStackTrace();
}
}
@Override
public void onClick(View view) {
try {
switch (view.getId()) {
case R.id.btnNetworkQuality:
checkBandwidth();
break;
}
} catch (Exception e) {
e.printStackTrace();
}
}
private void checkBandwidth() {
Log.e("checkBandwidth() ", " ");
ConnectionQuality connectionQuality = AndroidNetworking.getCurrentConnectionQuality();
if(connectionQuality == ConnectionQuality.EXCELLENT) {
Log.e("Good quality "," ==> ");
// do something
} else if (connectionQuality == ConnectionQuality.POOR) {
Log.e("Poor quality "," ==> ");
} else if (connectionQuality == ConnectionQuality.UNKNOWN) {
Log.e("Unnown"," ==> ");
}
}
}