Advertisement
Guest User

Untitled

a guest
Nov 11th, 2013
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.68 KB | None | 0 0
  1. package com.zoltrix.gpsallinfo;
  2.  
  3. import com.zoltrix.gpsallinfo.R.id;
  4.  
  5. import android.os.Bundle;
  6. import android.app.Activity;
  7. import android.content.Intent;
  8. import android.view.Menu;
  9. import android.view.MenuItem;
  10. import android.widget.TextView;
  11. import android.widget.Toast;
  12.  
  13. public class MainActivity extends Activity {
  14.  
  15.     double lat, lon;
  16.     TextView latData, longData;
  17.  
  18.     @Override
  19.     protected void onCreate(Bundle savedInstanceState) {
  20.         super.onCreate(savedInstanceState);
  21.         setContentView(R.layout.activity_main);
  22.         latData = (TextView) findViewById(R.id.latData);
  23.         longData = (TextView) findViewById(R.id.longData);
  24.  
  25.         LiczydloGPS gps = new LiczydloGPS(this);
  26.  
  27.         if (gps.canGetLocation() != true) {
  28.             gps.showSettingsAlert();
  29.  
  30.         } else {
  31.  
  32.             lat = gps.getLatitude(); // returns latitude
  33.             lon = gps.getLongitude();
  34.             latData.setText(String.valueOf(lat));
  35.             longData.setText(String.valueOf(lon));
  36.         }
  37.  
  38.     }
  39.  
  40.     @Override
  41.     public boolean onCreateOptionsMenu(Menu menu) {
  42.         // Inflate the menu; this adds items to the action bar if it is present.
  43.         getMenuInflater().inflate(R.menu.main, menu);
  44.  
  45.         return true;
  46.     }
  47.  
  48.     @Override
  49.     public boolean onOptionsItemSelected(MenuItem item) {
  50.         // TODO Auto-generated method stub
  51.         switch (item.getItemId()) {
  52.  
  53.         case id.oprogramie:
  54.  
  55.             Intent intent = new Intent(this, Oprogramie.class);
  56.             startActivity(intent);
  57.         case id.action_settings:
  58.             Intent intent2 = new Intent(this, Ustawienia.class);
  59.             startActivity(intent2);
  60.         }
  61.  
  62.         return super.onOptionsItemSelected(item);
  63.     }
  64.  
  65.     public void update(double lat1, double lon1) {
  66.  
  67.         latData.setText(String.valueOf(lat1));
  68.         longData.setText(String.valueOf(lon1));
  69.  
  70.     }
  71.  
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement