I've been struggling with this for awhile and decided to ask fro some help. I've read the literature but still can't seem to make this code work for me. I'm using Fedor's code to try to return location and display it with my intent. I want the time/date and location to display in my next activity. The time/date is working fine I'm having trouble initiating the MyLocation class and passing that value to the intent. Any help or pointing to any other resources would be cool. Thanks.
Here's what I have I have so far.
package com.tree;
import java.util.Calendar;
import android.app.Activity;
import android.content.Intent;
import android.location.Location;
import android.os.Bundle;
import android.view.View;
import com.tree.MyLocation.LocationResult;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
LocationResult locationResult = new LocationResult(){
@Override
public void gotLocation(Location location){
//Got the location!
}
};
MyLocation myLocation = new MyLocation();
myLocation.getLocation(this, locationResult);
public void clockin (View view){
Intent intent = new Intent (this, Mainmenu.class);
String timedate = java.text.DateFormat.getDateTimeInstance().format(Calendar.getInstance().getTime()) , locationResult;
intent.putExtra("TIME_DATE", timedate);
startActivity(intent);
}
}
This is my first app