root / src / com / rackspacecloud / android / PingServerActivity.java @ 48601850
History | View | Annotate | Download (999 Bytes)
1 |
package com.rackspacecloud.android; |
---|---|
2 |
|
3 |
import android.app.Activity; |
4 |
import android.os.Bundle; |
5 |
import android.webkit.WebView; |
6 |
|
7 |
import com.rackspace.cloud.android.R; |
8 |
|
9 |
public class PingServerActivity extends Activity{ |
10 |
|
11 |
private WebView pingSiteView;
|
12 |
private String ipAddress; |
13 |
private final String url = "http://just-ping.com/index.php?vh=&c=&s=ping!"; |
14 |
|
15 |
public void onCreate(Bundle savedInstanceState){ |
16 |
super.onCreate(savedInstanceState);
|
17 |
setContentView(R.layout.viewpingserver); |
18 |
ipAddress = (String) this.getIntent().getExtras().get("ipAddress"); |
19 |
String urlWIp = getUrl(ipAddress);
|
20 |
pingSiteView = (WebView) findViewById(R.id.ping_server_webview); |
21 |
//just-ping.com uses javascript to make requests
|
22 |
pingSiteView.getSettings().setJavaScriptEnabled(true);
|
23 |
pingSiteView.loadUrl(urlWIp); |
24 |
|
25 |
} |
26 |
|
27 |
private String getUrl(String ip){ |
28 |
//put the ip address into the appropriate location in the url
|
29 |
return url.substring(0, url.indexOf("=")+1) + ip + url.substring(url.indexOf("&")); |
30 |
|
31 |
} |
32 |
|
33 |
} |