forked from aanchal298/location
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GeocodingActivity.java
77 lines (63 loc) · 2.36 KB
/
GeocodingActivity.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package com.example.location;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.IOException;
import android.app.Activity;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
public class GeocodingActivity extends Activity {
Button addressButton;
TextView lattv;
TextView longtv;
String adr;
static String aString,bb;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.geocodingactivity);
lattv = (TextView) findViewById(R.id.textView1);
longtv = (TextView) findViewById(R.id.textView2);
addressButton = (Button) findViewById(R.id.button1);
addressButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
GeocodingLocation locationAddress = new GeocodingLocation();
locationAddress.getAddressFromLocation(JobList.job2,getApplicationContext(), new GeocoderHandler());
// Toast.makeText(getApplicationContext(), aString, Toast.LENGTH_SHORT);
}
});
}
private class GeocoderHandler extends Handler {
@Override
public void handleMessage(Message message) {
switch (message.what) {
case 1:
Bundle bundle = message.getData();
double arr[]=bundle.getDoubleArray("address");
double aDouble = arr[0];
aString = Double.toString(aDouble);
double b = arr[1];
bb = Double.toString(b);
break;
default:
aString = null;
bb=null;
}
longtv.setText(aString);
lattv.setText(bb);
Toast.makeText(getApplicationContext(), aString, Toast.LENGTH_SHORT).show();
Intent i=new Intent(GeocodingActivity.this,UpdateFile.class);
startActivity(i);
}
}
}