mirror of
http://galexander.org/git/simplesshd.git
synced 2025-01-03 19:50:55 +00:00
get the ip address of the device using wifimanager, which only works if
we're on wifi, and needs a new permission
This commit is contained in:
parent
6172cf73e1
commit
615e835880
@ -7,6 +7,7 @@
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<application android:label="SimpleSSHD" android:icon="@drawable/icon">
|
||||
<activity android:name="SimpleSSHD" android:label="SimpleSSHD">
|
||||
<intent-filter>
|
||||
|
@ -3,6 +3,14 @@
|
||||
android:orientation="vertical"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent">
|
||||
<TextView android:id="@+id/ip"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium"
|
||||
android:typeface="monospace"
|
||||
android:singleLine="true"
|
||||
android:background="#ff112266"
|
||||
android:text="IP: XXX" />
|
||||
<EditText android:id="@+id/log"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="1dp"
|
||||
|
@ -16,12 +16,15 @@ import android.net.Uri;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.BufferedReader;
|
||||
import android.net.wifi.WifiManager;
|
||||
import android.net.wifi.WifiInfo;
|
||||
|
||||
public class SimpleSSHD extends Activity
|
||||
{
|
||||
private static final Object lock = new Object();
|
||||
private EditText log_view;
|
||||
private Button startstop_view;
|
||||
private TextView ip_view;
|
||||
public static SimpleSSHD curr = null;
|
||||
private UpdaterThread updater = null;
|
||||
|
||||
@ -31,6 +34,7 @@ public class SimpleSSHD extends Activity
|
||||
setContentView(R.layout.main);
|
||||
log_view = (EditText)findViewById(R.id.log);
|
||||
startstop_view = (Button)findViewById(R.id.startstop);
|
||||
ip_view = (TextView)findViewById(R.id.ip);
|
||||
}
|
||||
|
||||
public void onResume() {
|
||||
@ -41,6 +45,7 @@ public class SimpleSSHD extends Activity
|
||||
update_startstop_prime();
|
||||
updater = new UpdaterThread();
|
||||
updater.start();
|
||||
ip_view.setText("IP: "+get_ip());
|
||||
}
|
||||
|
||||
public void onPause() {
|
||||
@ -157,4 +162,15 @@ public class SimpleSSHD extends Activity
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public String get_ip() {
|
||||
WifiManager wm = (WifiManager)getSystemService(Context.WIFI_SERVICE);
|
||||
WifiInfo wi = wm.getConnectionInfo();
|
||||
int ip = wi.getIpAddress();
|
||||
return
|
||||
String.valueOf((ip>>0)&0xff) + "." +
|
||||
String.valueOf((ip>>8)&0xff) + "." +
|
||||
String.valueOf((ip>>16)&0xff) + "." +
|
||||
String.valueOf((ip>>24)&0xff);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user