seetharam1000
Newbie
Bold line in this coding have errors at the time of running, please give me the solution for that.
package com.gps;
import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class GpsLocationActivity extends Activity {
protected static final TextView et_field_name = null;
/** Called when the activity is first created. */
public static double latitude;
public static double longitude;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button btn_show_location= (Button)findViewById(R.id.button1);
public class MyLocationListener implements LocationListener {
public static double latitude;
public static double longitude;
public void onLocationChanged(Location loc)
{
loc.getLatitude();
loc.getLongitude();
latitude=loc.getLatitude();
longitude=loc.getLongitude();
}
public void onProviderDisabled(String provider)
{
//print "Currently GPS is Disabled";
}
public void onProviderEnabled(String provider)
{
//print "GPS got Enabled";
}
public void onStatusChanged(String provider, int status, Bundle extras)
{
}
}
btn_show_location.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
LocationManager mlocManager=null;
LocationListener mlocListener;
mlocManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
mlocListener = new MyLocationListener();
mlocManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 0, 0, mlocListener);
if (mlocManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
if(MyLocationListener.latitude>0)
{
et_field_name.append("Latitude:- " + MyLocationListener.latitude + '\n');
et_field_name.append("Longitude:- " + MyLocationListener.longitude + '\n');
}
else
{
alert.setTitle("Wait");
alert.setMessage("GPS in progress, please wait.");
alert.setPositiveButton("OK", null);
alert.show();
}
} else {
et_field_name.setText("GPS is not turned on...");
}
}
});
}
}
package com.gps;
import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class GpsLocationActivity extends Activity {
protected static final TextView et_field_name = null;
/** Called when the activity is first created. */
public static double latitude;
public static double longitude;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button btn_show_location= (Button)findViewById(R.id.button1);
public class MyLocationListener implements LocationListener {
public static double latitude;
public static double longitude;
public void onLocationChanged(Location loc)
{
loc.getLatitude();
loc.getLongitude();
latitude=loc.getLatitude();
longitude=loc.getLongitude();
}
public void onProviderDisabled(String provider)
{
//print "Currently GPS is Disabled";
}
public void onProviderEnabled(String provider)
{
//print "GPS got Enabled";
}
public void onStatusChanged(String provider, int status, Bundle extras)
{
}
}
btn_show_location.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
LocationManager mlocManager=null;
LocationListener mlocListener;
mlocManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
mlocListener = new MyLocationListener();
mlocManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 0, 0, mlocListener);
if (mlocManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
if(MyLocationListener.latitude>0)
{
et_field_name.append("Latitude:- " + MyLocationListener.latitude + '\n');
et_field_name.append("Longitude:- " + MyLocationListener.longitude + '\n');
}
else
{
alert.setTitle("Wait");
alert.setMessage("GPS in progress, please wait.");
alert.setPositiveButton("OK", null);
alert.show();
}
} else {
et_field_name.setText("GPS is not turned on...");
}
}
});
}
}