title: Android : GPS tracking system for find each other in a close area
body: <p>I have to develop an Android app, what this app is supposed to do is help people find each other in a close area without wasting too much power. Both people can use the app with the phone in their palm facing up to find each other. It can use gps to give an initial direction to travel(Forward, left, right, backwards). It can then use bluetooth and wifi strength to give the users a general idea of whether they are getting closer or farther. It does not need to give the specific distance between the phones. </p>
  
  <p>I've followed this(<a href="http://www.androidhive.info/2012/07/android-gps-location-manager-tutorial/" rel="nofollow">http://www.androidhive.info/2012/07/android-gps-location-manager-tutorial/</a>) tutorial and it works fine. But I have no idea how to use this in my app.</p>
  
  <p>I am a trainee of developing Android applications and I am new to GPS tracking systems. Actually I have no clear idea about how to start this app. </p>
  
  <p>Here is my attempt.</p>
  
  <p>My xml file:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:paddingBottom="@dimen/activity_vertical_margin"
  android:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin"
  tools:context=".MainActivity" &gt;
  
  &lt;Button
      android:id="@+id/button2"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignBaseline="@+id/button1"
      android:layout_alignBottom="@+id/button1"
      android:layout_alignParentRight="true"
      android:onClick="stopNewService"
      android:text="Stop Service" /&gt;
  
  &lt;Button
      android:id="@+id/button1"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentLeft="true"
      android:layout_alignParentTop="true"
      android:layout_marginTop="23dp"
      android:onClick="startNewService"
      android:text="Start Service" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>This is my MyService.java class</p>
  
  <pre><code>package com.example.service;
  
  import android.app.Service;
  import android.content.Intent;
  import android.os.IBinder;
  import android.widget.Toast;
  
  public class MyService extends Service {
  
  @Override
  public IBinder onBind(Intent intent) {
      // TODO Auto-generated method stub
      return null;
  }
  
  @Override
  public void onCreate() {
      Toast.makeText(this, "The new Service was Created", Toast.LENGTH_LONG)
              .show();
  
  }
  
  @Override
  public void onStart(Intent intent, int startId) {
      // For time consuming an long tasks you can launch a new thread here...
      Toast.makeText(this, " Service Started", Toast.LENGTH_LONG).show();
  
  }
  
  @Override
  public void onDestroy() {
      Toast.makeText(this, "Service Destroyed", Toast.LENGTH_LONG).show();
  
  }
  
  }
  </code></pre>
  
  <p>And here is my MainActivity.java class</p>
  
  <pre><code>package com.example.service;
  
  import android.os.Bundle;
  import android.app.Activity;
  import android.content.Intent;
  import android.view.Menu;
  import android.view.View;
  import android.widget.Button;
  
  public class MainActivity extends Activity implements View.OnClickListener {
  private Button bStart, bStop;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  }
  
  // Start the service
  public void startNewService(View view) {
  
      startService(new Intent(this, MyService.class));
  }
  
  // Stop the service
  public void stopNewService(View view) {
  
      stopService(new Intent(this, MyService.class));
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.main, menu);
      return true;
  }
  
  @Override
  public void onClick(View v) {
      // TODO Auto-generated method stub
      switch (v.getId()) {
      case R.id.button1:
          startNewService(v);
  
          break;
      case R.id.button2:
          stopNewService(v);
  
          break;
  
      default:
          break;
      }
  }
  
  }
  </code></pre>
  
  <p>I've added the service into manifest file.</p>
  
  <pre><code>&lt;service android:name=".MyService"&gt;&lt;/service&gt;
  </code></pre>
  
  <p>Furthermore I can get the locations of each devices but the problem is how should I send and receive those data between two devices.</p>
  
  <p>I would be much thankful if anyone please be so kind enough to help me to clarify this.</p>
  
  <p>Thanks in advance.</p>