英文:
How to get RSSI value from Wifi on different device?
问题
private class HostsAdapter extends ArrayAdapter<Void> {
public HostsAdapter(Context ctxt) {
super(ctxt, R.layout.list_host, R.id.list);
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder;
View view = convertView;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.list_host, null);
holder = new ViewHolder();
holder.host = (TextView) convertView.findViewById(R.id.list);
holder.mac = (TextView) convertView.findViewById(R.id.mac);
holder.vendor = (TextView) convertView.findViewById(R.id.vendor);
holder.logo = (ImageView) convertView.findViewById(R.id.logo);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
final HostBean host = hosts.get(position);
if (host.deviceType == HostBean.TYPE_GATEWAY) {
holder.logo.setImageResource(R.drawable.router);
} else if (host.isAlive == 1 || !host.hardwareAddress.equals(NetInfo.NOMAC)) {
holder.logo.setImageResource(R.drawable.computer);
} else {
holder.logo.setImageResource(R.drawable.computer);
}
if (host.hostname != null && !host.hostname.equals(host.ipAddress) && !host.hostname.equals(host.rssi)) {
holder.host.setText(host.hostname + " (" + host.ipAddress + ")");
} else {
holder.host.setText(host.ipAddress);
}
if (!host.hardwareAddress.equals(NetInfo.NOMAC)) {
holder.mac.setText(host.hardwareAddress);
if(host.nicVendor != null){
holder.vendor.setText(host.nicVendor);
} else {
holder.vendor.setText(R.string.info_unknown);
}
holder.mac.setVisibility(View.VISIBLE);
holder.vendor.setVisibility(View.VISIBLE);
} else {
holder.mac.setVisibility(View.GONE);
holder.vendor.setVisibility(View.GONE);
}
return convertView;
}
}
英文:
> Hello, i have new project about indoor positioning. After detect users and get ip address and mac from device who connect in Router, so i'm confused how to get rssi value on that users. Is possible right? Somebody pls help me this is my thesis, thankyouu
I used android studio btw.. This is my code to display ip address, mac, and SSID device who connect to wifi
private class HostsAdapter extends ArrayAdapter<Void> {
public HostsAdapter(Context ctxt) {
super(ctxt, R.layout.list_host, R.id.list);
}
@Override
public View getView(final int position, View convertView, ViewGroup parent) {
ViewHolder holder;
View view = convertView;
if (convertView == null) {
convertView = mInflater.inflate(R.layout.list_host, null);
holder = new ViewHolder();
holder.host = (TextView) convertView.findViewById(R.id.list);
holder.mac = (TextView) convertView.findViewById(R.id.mac);
holder.vendor = (TextView) convertView.findViewById(R.id.vendor);
holder.logo = (ImageView) convertView.findViewById(R.id.logo);
convertView.setTag(holder);
} else {
holder = (ViewHolder) convertView.getTag();
}
final HostBean host = hosts.get(position);
if (host.deviceType == HostBean.TYPE_GATEWAY) {
holder.logo.setImageResource(R.drawable.router);
} else if (host.isAlive == 1 || !host.hardwareAddress.equals(NetInfo.NOMAC)) {
holder.logo.setImageResource(R.drawable.computer);
} else {
holder.logo.setImageResource(R.drawable.computer);
}
if (host.hostname != null && !host.hostname.equals(host.ipAddress) && !host.hostname.equals(host.rssi)) {
holder.host.setText(host.hostname + " (" + host.ipAddress + ")");
} else {
holder.host.setText(host.ipAddress);
}
if (!host.hardwareAddress.equals(NetInfo.NOMAC)) {
holder.mac.setText(host.hardwareAddress);
if(host.nicVendor != null){
holder.vendor.setText(host.nicVendor);
} else {
holder.vendor.setText(R.string.info_unknown);
}
holder.mac.setVisibility(View.VISIBLE);
holder.vendor.setVisibility(View.VISIBLE);
} else {
holder.mac.setVisibility(View.GONE);
holder.vendor.setVisibility(View.GONE);
}
return convertView;
}
}
专注分享java语言的经验与见解,让所有开发者获益!
评论