1 |
torben |
1519 |
package dk.thoerup.telmorewidget; |
2 |
|
|
|
3 |
|
|
import java.io.IOException; |
4 |
|
|
|
5 |
|
|
import android.app.Activity; |
6 |
|
|
import android.os.Bundle; |
7 |
|
|
import android.view.View; |
8 |
|
|
import android.view.View.OnClickListener; |
9 |
|
|
import android.widget.Button; |
10 |
|
|
import android.widget.TextView; |
11 |
|
|
import android.widget.Toast; |
12 |
|
|
import dk.thoerup.telmorewidget.TelmoreFetcher.Result; |
13 |
|
|
|
14 |
|
|
|
15 |
|
|
public class TelmoreActivity extends Activity { |
16 |
|
|
|
17 |
|
|
@Override |
18 |
|
|
public void onCreate(Bundle savedInstanceState) { |
19 |
|
|
super.onCreate(savedInstanceState); |
20 |
|
|
setContentView(R.layout.main); |
21 |
|
|
|
22 |
|
|
Button b = (Button) findViewById(R.id.button); |
23 |
|
|
b.setOnClickListener( new OnClickListener() { |
24 |
|
|
|
25 |
|
|
|
26 |
|
|
public void onClick(View v) { |
27 |
|
|
TelmoreFetcher fetcher = new TelmoreFetcher(); |
28 |
|
|
try { |
29 |
|
|
|
30 |
|
|
Result res = fetcher.fetch("", ""); |
31 |
|
|
( (TextView)findViewById(R.id.saldo) ).setText( res.saldo ); |
32 |
|
|
( (TextView)findViewById(R.id.internet) ).setText( res.internetUsage ); |
33 |
|
|
|
34 |
|
|
} catch (IOException e) { |
35 |
|
|
Toast.makeText(TelmoreActivity.this, e.getMessage(), Toast.LENGTH_LONG).show(); |
36 |
|
|
e.printStackTrace(); |
37 |
|
|
} |
38 |
|
|
|
39 |
|
|
} |
40 |
|
|
}); |
41 |
|
|
|
42 |
|
|
} |
43 |
|
|
|
44 |
|
|
} |