Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 16th, 2012  |  syntax: None  |  size: 1.85 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. android: find current location in map and save it as a picture
  2. public class newGameSetUp extends Activity{
  3.  
  4. private static final int SELECT_PICTURE = 1;
  5. private String selectedImagePath=""; //path of the image selected
  6. private String filemanagerstring;
  7. Bitmap bMap = null;
  8. ImageView img;
  9. Button newgame;
  10.  
  11. private static final long MINIMUM_DISTANCE_CHANGE_FOR_UPDATES = 1; // in Meters
  12. private static final long MINIMUM_TIME_BETWEEN_UPDATES = 1000; // in Milliseconds
  13. protected LocationManager locationManager;
  14.  
  15. public void onCreate(Bundle savedInstanceState) {
  16.      super.onCreate(savedInstanceState);
  17.       setTitle("Picture Puzzle");
  18.      setContentView(R.layout.newscreen);
  19.     newgame = (Button)findViewById(R.id.button2);
  20.     newgame.setTextColor(Color.GRAY);
  21.      final Button back = (Button)findViewById(R.id.button3);
  22.      img = (ImageView)findViewById(R.id.imageView1);
  23.      final Button load = (Button)findViewById(R.id.button1);
  24.      final RadioGroup mRadioGroup = (RadioGroup) findViewById(R.id.radioGroup1);
  25.  
  26.      final Button map = (Button)findViewById(R.id.button4);        
  27.      locationManager.requestLocationUpdates(
  28.                 LocationManager.GPS_PROVIDER,
  29.                 MINIMUM_TIME_BETWEEN_UPDATES,
  30.                 MINIMUM_DISTANCE_CHANGE_FOR_UPDATES,
  31.                 new MyLocationListener()
  32.         );
  33.      map.setOnClickListener(new OnClickListener(){
  34.             @Override
  35.             public void onClick(View arg0) {        
  36.                 Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
  37.                 String address = (location.getLongitude()+" "+ location.getLatitude());
  38.                 address.replace(' ', '+');
  39.                 Intent geoIntent = new Intent(android.content.Intent.ACTION_VIEW, Uri.parse("geo:0,0?q=" + address));
  40.                 startActivity(geoIntent);
  41.  
  42.             }      
  43.        });