hello i am new in android so i want to know how to get the the time intervals in android so please help me to find the time intervals in this program?my teacher said in time stamp subtract one time to another time?how to do it?
public class MainActivity extends Activity {
private Button myLocation;
private TextView myAddress;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
myLocation = (Button) findViewById(R.id.location);
myAddress = (TextView) findViewById(R.id.address);
myLocation.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getMyLocationAddress();
}
});
}
public void getMyLocationAddress() {
Geocoder geocoder= new Geocoder(this, Locale.ENGLISH);
try {
// Place your latitude and longitude
List<Address> addresses = geocoder.getFromLocation(28.437582, 76.995242, 1);
if (addresses != null) {
Address fetchedAddress = addresses.get(0);
StringBuilder strAddress = new StringBuilder();
for (int i = 0; i < fetchedAddress.getMaxAddressLineIndex(); i++) {
strAddress.append(fetchedAddress.getAddressLine(i)).append("\n");
}
myAddress.setText("I am at: " + strAddress.toString());
} else
myAddress.setText("No location found..!");
} catch (IOException e) {
e.printStackTrace();
Toast.makeText(getApplicationContext(),"Could not get a address..!",Toast.LENGTH_LONG).show();
}
}
}