[android-developers] Re: How to make a Service That will periodically send the Users Location on a server

2013-10-05 Thread Richard Schilling
There are cases where you won't get a location even when things are setup 
right.  This may help:

http://rschilling.wordpress.com/2011/01/05/some-android-and-not-android-gps-best-practices/



On Thursday, October 3, 2013 7:55:23 AM UTC-7, HImanshu Mittal wrote:

 Hello

 I am building the app that requires that users location has to be updated 
 on my server periodically or to be more efficient only when its location 
 has been updated.
 For that a Service will run on its device.
 But I am not able to develop that till now haven't found that does that 
 perfectly.
 Please help


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [android-developers] Re: How to make a Service That will periodically send the Users Location on a server

2013-10-05 Thread HImanshu Mittal
But Sir I have a question than ,
How a blue dot is availaible at the position where I am , but the function
is not able to fetch the data than...
??


On Sun, Oct 6, 2013 at 12:19 AM, Richard Schilling coderroa...@gmail.comwrote:

 There are cases where you won't get a location even when things are setup
 right.  This may help:


 http://rschilling.wordpress.com/2011/01/05/some-android-and-not-android-gps-best-practices/



 On Thursday, October 3, 2013 7:55:23 AM UTC-7, HImanshu Mittal wrote:

 Hello

 I am building the app that requires that users location has to be updated
 on my server periodically or to be more efficient only when its location
 has been updated.
 For that a Service will run on its device.
 But I am not able to develop that till now haven't found that does that
 perfectly.
 Please help

  --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en
 ---
 You received this message because you are subscribed to a topic in the
 Google Groups Android Developers group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/android-developers/cFXbDUmDh6E/unsubscribe
 .
 To unsubscribe from this group and all its topics, send an email to
 android-developers+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [android-developers] Re: How to make a Service That will periodically send the Users Location on a server

2013-10-05 Thread Kristopher Micinski
You can ask for the last known location.

Kris
On Oct 5, 2013 3:33 PM, HImanshu Mittal himanshu5...@gmail.com wrote:

 But Sir I have a question than ,
 How a blue dot is availaible at the position where I am , but the function
 is not able to fetch the data than...
 ??


 On Sun, Oct 6, 2013 at 12:19 AM, Richard Schilling 
 coderroa...@gmail.comwrote:

 There are cases where you won't get a location even when things are setup
 right.  This may help:


 http://rschilling.wordpress.com/2011/01/05/some-android-and-not-android-gps-best-practices/



 On Thursday, October 3, 2013 7:55:23 AM UTC-7, HImanshu Mittal wrote:

 Hello

 I am building the app that requires that users location has to be
 updated on my server periodically or to be more efficient only when its
 location has been updated.
 For that a Service will run on its device.
 But I am not able to develop that till now haven't found that does that
 perfectly.
 Please help

  --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en
 ---
 You received this message because you are subscribed to a topic in the
 Google Groups Android Developers group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/android-developers/cFXbDUmDh6E/unsubscribe
 .
 To unsubscribe from this group and all its topics, send an email to
 android-developers+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


  --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Android Developers group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to android-developers+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [android-developers] Re: How to make a Service That will periodically send the Users Location on a server

2013-10-05 Thread HImanshu Mittal
I did that only , but than it is giving it null ...
hahaha...
Everything is happening !!!


On Sun, Oct 6, 2013 at 1:17 AM, Kristopher Micinski
krismicin...@gmail.comwrote:

 You can ask for the last known location.

 Kris
 On Oct 5, 2013 3:33 PM, HImanshu Mittal himanshu5...@gmail.com wrote:

 But Sir I have a question than ,
 How a blue dot is availaible at the position where I am , but the
 function is not able to fetch the data than...
 ??


 On Sun, Oct 6, 2013 at 12:19 AM, Richard Schilling coderroa...@gmail.com
  wrote:

 There are cases where you won't get a location even when things are
 setup right.  This may help:


 http://rschilling.wordpress.com/2011/01/05/some-android-and-not-android-gps-best-practices/



 On Thursday, October 3, 2013 7:55:23 AM UTC-7, HImanshu Mittal wrote:

 Hello

 I am building the app that requires that users location has to be
 updated on my server periodically or to be more efficient only when its
 location has been updated.
 For that a Service will run on its device.
 But I am not able to develop that till now haven't found that does that
 perfectly.
 Please help

  --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en
 ---
 You received this message because you are subscribed to a topic in the
 Google Groups Android Developers group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/android-developers/cFXbDUmDh6E/unsubscribe
 .
 To unsubscribe from this group and all its topics, send an email to
 android-developers+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


  --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Android Developers group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to android-developers+unsubscr...@googlegroups.com.

 For more options, visit https://groups.google.com/groups/opt_out.

  --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en
 ---
 You received this message because you are subscribed to a topic in the
 Google Groups Android Developers group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/android-developers/cFXbDUmDh6E/unsubscribe
 .
 To unsubscribe from this group and all its topics, send an email to
 android-developers+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [android-developers] Re: How to make a Service That will periodically send the Users Location on a server

2013-10-05 Thread Kristopher Micinski
If that's the case, I'd say the app is manually caching it, but I don't
know the exact details.

Kris



On Sat, Oct 5, 2013 at 4:20 PM, HImanshu Mittal himanshu5...@gmail.comwrote:

 I did that only , but than it is giving it null ...
 hahaha...
 Everything is happening !!!


 On Sun, Oct 6, 2013 at 1:17 AM, Kristopher Micinski 
 krismicin...@gmail.com wrote:

 You can ask for the last known location.

 Kris
 On Oct 5, 2013 3:33 PM, HImanshu Mittal himanshu5...@gmail.com wrote:

 But Sir I have a question than ,
 How a blue dot is availaible at the position where I am , but the
 function is not able to fetch the data than...
 ??


 On Sun, Oct 6, 2013 at 12:19 AM, Richard Schilling 
 coderroa...@gmail.com wrote:

 There are cases where you won't get a location even when things are
 setup right.  This may help:


 http://rschilling.wordpress.com/2011/01/05/some-android-and-not-android-gps-best-practices/



 On Thursday, October 3, 2013 7:55:23 AM UTC-7, HImanshu Mittal wrote:

 Hello

 I am building the app that requires that users location has to be
 updated on my server periodically or to be more efficient only when its
 location has been updated.
 For that a Service will run on its device.
 But I am not able to develop that till now haven't found that does
 that perfectly.
 Please help

  --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to
 android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en
 ---
 You received this message because you are subscribed to a topic in the
 Google Groups Android Developers group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/android-developers/cFXbDUmDh6E/unsubscribe
 .
 To unsubscribe from this group and all its topics, send an email to
 android-developers+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


  --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en
 ---
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To unsubscribe from this group and stop receiving emails from it, send
 an email to android-developers+unsubscr...@googlegroups.com.

 For more options, visit https://groups.google.com/groups/opt_out.

  --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en
 ---
 You received this message because you are subscribed to a topic in the
 Google Groups Android Developers group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/android-developers/cFXbDUmDh6E/unsubscribe
 .
 To unsubscribe from this group and all its topics, send an email to
 android-developers+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


  --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Android Developers group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to android-developers+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [android-developers] Re: How to make a Service That will periodically send the Users Location on a server

2013-10-05 Thread Richard Schilling
to answer your question - it depends on what Google Maps is doing to 
resolve your location.

If I understand you correctly, you're using the Google Maps api to display 
current location, and you're comparing that location (which always seems 
available) with the location information that the LocationManager provides 
you.  Is that correct?

If that is, then there are a couple things that could be happening:

1. Google Maps could be resolving your location through some other means, 
which includes contacting your phone's carrier to get a fix (Assisted GPS).
2. Google Maps could be using it's own way to resolve your location based 
on a cell tower.  Google uses a database for this purpose.


In any case, you should expect to see a difference (not that you always 
will - but expect it to be so), between what you see on Google maps and 
what LocationManager tells you.

Hope that helps.

Cheers,
Richard



On Saturday, October 5, 2013 12:29:51 PM UTC-7, HImanshu Mittal wrote:

 But Sir I have a question than ,
 How a blue dot is availaible at the position where I am , but the function 
 is not able to fetch the data than...
 ??


 On Sun, Oct 6, 2013 at 12:19 AM, Richard Schilling 
 coder...@gmail.comjavascript:
  wrote:

 There are cases where you won't get a location even when things are setup 
 right.  This may help:


 http://rschilling.wordpress.com/2011/01/05/some-android-and-not-android-gps-best-practices/



 On Thursday, October 3, 2013 7:55:23 AM UTC-7, HImanshu Mittal wrote:

 Hello

 I am building the app that requires that users location has to be 
 updated on my server periodically or to be more efficient only when its 
 location has been updated.
 For that a Service will run on its device.
 But I am not able to develop that till now haven't found that does that 
 perfectly.
 Please help

  -- 



-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [android-developers] Re: How to make a Service That will periodically send the Users Location on a server

2013-10-04 Thread HImanshu Mittal
Hello friends,
I have just checked it out that my service is working fine but the problem
is I am in an area where location is unavalaible and my friend is in an
area where location is availaible.
How should* *I fix this that my location also can be transmitted to my
server!!!

Now I think ii could be solved
Please Help!!


On Fri, Oct 4, 2013 at 9:47 AM, HImanshu Mittal himanshu5...@gmail.comwrote:

 package com.example.metro;

 import com.dude5692.StaticURL.ProjectURL;

 import json.jSOn;

 import android.app.Service;
 import android.content.Context;
 import android.content.Intent;
 import android.content.SharedPreferences;
 import android.location.Criteria;
 import android.location.Location;
 import android.location.LocationListener;
 import android.location.LocationManager;
 import android.os.AsyncTask;
 import android.os.Bundle;
 import android.os.IBinder;
 import android.widget.Toast;

 public class MyService extends Service
 {
 ProjectURL proURL = new ProjectURL();
 String initialURL;
  SharedPreferences pref;

 @Override
 public void onCreate()
  {
 // TODO Auto-generated method stub
 super.onCreate();
  final LocationManager mlocmag =
 (LocationManager)getSystemService(Context.LOCATION_SERVICE);
 final LocationListener mlocList = new MyLocationList();

 Criteria criteria = new Criteria();

 // Getting the name of the best provider
  final String provider = mlocmag.getBestProvider(criteria, true);

 final Location loc = mlocmag.getLastKnownLocation(provider);
  UpdateWithNewLocation(loc); // This method is used to get updated
 location.
 mlocmag.requestLocationUpdates(provider, 1000, 0, mlocList);
  }

 @Override
 public IBinder onBind(Intent arg0)
  {
 // TODO Auto-generated method stub
 return null;
  }

 @Override
 public void onDestroy()
  {
 // TODO Auto-generated method stub
 super.onDestroy();
  }

 @Override
 public int onStartCommand(Intent intent, int flags, int startId)
  {
 // TODO Auto-generated method stub
 return super.onStartCommand(intent, flags, startId);
  }
 private void UpdateWithNewLocation(final Location loc)
 {
  // TODO Auto-generated method stub
 if(loc!= null)
 {
  final double lat =loc.getLatitude(); // Updated lat
 final double Long = loc.getLongitude(); // Updated long

 pref = getSharedPreferences(myMetroFile,Context.MODE_PRIVATE);
  System.out.println(MO   Service Running);
  String UniqueDeviceId = pref.getString(DeviceUniqueID, 0);
 initialURL = proURL.projectURL +
 storeLatLong.php?RegID=+lat+Email=+Long+Device=+UniqueDeviceId+Start=NO;
  new Async().execute();
 }
 else
 {
  }
 }

 class Async extends AsyncTaskString, Void, String
  {

 //ProgressDialog progress;

 protected String doInBackground(String... params)
  {
 try
 {
  new jSOn().execute(initialURL);
 }
 catch (Exception e)
  {
 e.printStackTrace();
 }
  return null;
 }

 protected void onPreExecute()
  {
 super.onPreExecute();
 }

  protected void onPostExecute(String result)
 {
 super.onPostExecute(result);
  }
 }

 public class MyLocationList implements LocationListener
  {

 public void onLocationChanged(Location arg0)
 {
  // TODO Auto-generated method stub
 UpdateWithNewLocation(arg0);
 }

 public void onProviderDisabled(String provider)
 {
 // TODO Auto-generated method stub
  Toast.makeText(getApplicationContext(),GPS Disable ,
 Toast.LENGTH_LONG).show();
 }

  public void onProviderEnabled(String provider)
 {
 // TODO Auto-generated method stub
  Toast.makeText(getApplicationContext(),GPS enabled,
 Toast.LENGTH_LONG).show();
 }

  public void onStatusChanged(String provider, int status, Bundle extras)
 {
 // TODO Auto-generated method stub
  }
 }
 }


 On Fri, Oct 4, 2013 at 4:44 AM, Lew lewbl...@gmail.com wrote:

  HImanshu Mittal wrote:

 Bro , Don't dramatize things out here. I have asked a question thats it.


 How is asking for relevant details dramatizing it?

 It's spelled that's.


 For the first the first time I have asked a question on any forum
 regarding a help in my 8 months of development time.


 Not important.


 I was not able to make a code because the code which I have made is not
 working.


 That's like telling a doctor, I don't feel well and expecting a
 diagnosis. You need to provide details.


 If you can provide the code than it will be really be helpful or I can
 also post my code out here than you can tell me where I am doing it wrong



 :)


 Since that's what the guy was asking for, why do you give him a hard
 time?


 On Thu, Oct 3, 2013 at 9:23 PM, Steve Gabrilowitz steve...@gmail.comwrote:

 You are more likely to get help developing your own service if tell us
 in which areas you have been less than successful.  If you are looking for
 a full piece of code already written for you then try Google ;-)

 Follow his advice.

 --
 Lew


 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 

Re: [android-developers] Re: How to make a Service That will periodically send the Users Location on a server

2013-10-04 Thread Kristopher Micinski
I guess the problem is, if your location is unavailable, how are you
expecting that that will be fixed?  This doesn't make any sense, if it's
not available, it's not available,

Kris



On Fri, Oct 4, 2013 at 6:16 AM, HImanshu Mittal himanshu5...@gmail.comwrote:

 Hello friends,
 I have just checked it out that my service is working fine but the problem
 is I am in an area where location is unavalaible and my friend is in an
 area where location is availaible.
 How should* *I fix this that my location also can be transmitted to my
 server!!!

 Now I think ii could be solved
 Please Help!!


 On Fri, Oct 4, 2013 at 9:47 AM, HImanshu Mittal himanshu5...@gmail.comwrote:

 package com.example.metro;

 import com.dude5692.StaticURL.ProjectURL;

 import json.jSOn;

 import android.app.Service;
 import android.content.Context;
 import android.content.Intent;
 import android.content.SharedPreferences;
 import android.location.Criteria;
 import android.location.Location;
 import android.location.LocationListener;
 import android.location.LocationManager;
 import android.os.AsyncTask;
 import android.os.Bundle;
 import android.os.IBinder;
 import android.widget.Toast;

 public class MyService extends Service
 {
 ProjectURL proURL = new ProjectURL();
 String initialURL;
  SharedPreferences pref;

 @Override
 public void onCreate()
  {
 // TODO Auto-generated method stub
 super.onCreate();
  final LocationManager mlocmag =
 (LocationManager)getSystemService(Context.LOCATION_SERVICE);
 final LocationListener mlocList = new MyLocationList();

 Criteria criteria = new Criteria();

 // Getting the name of the best provider
  final String provider = mlocmag.getBestProvider(criteria, true);

 final Location loc = mlocmag.getLastKnownLocation(provider);
  UpdateWithNewLocation(loc); // This method is used to get updated
 location.
 mlocmag.requestLocationUpdates(provider, 1000, 0, mlocList);
  }

 @Override
 public IBinder onBind(Intent arg0)
  {
 // TODO Auto-generated method stub
 return null;
  }

 @Override
 public void onDestroy()
  {
 // TODO Auto-generated method stub
 super.onDestroy();
  }

 @Override
 public int onStartCommand(Intent intent, int flags, int startId)
  {
 // TODO Auto-generated method stub
 return super.onStartCommand(intent, flags, startId);
  }
 private void UpdateWithNewLocation(final Location loc)
 {
  // TODO Auto-generated method stub
 if(loc!= null)
 {
  final double lat =loc.getLatitude(); // Updated lat
 final double Long = loc.getLongitude(); // Updated long

 pref = getSharedPreferences(myMetroFile,Context.MODE_PRIVATE);
  System.out.println(MO   Service Running);
  String UniqueDeviceId = pref.getString(DeviceUniqueID, 0);
 initialURL = proURL.projectURL +
 storeLatLong.php?RegID=+lat+Email=+Long+Device=+UniqueDeviceId+Start=NO;
  new Async().execute();
 }
 else
 {
  }
 }

 class Async extends AsyncTaskString, Void, String
  {

 //ProgressDialog progress;

 protected String doInBackground(String... params)
  {
 try
 {
  new jSOn().execute(initialURL);
 }
 catch (Exception e)
  {
 e.printStackTrace();
 }
  return null;
 }

 protected void onPreExecute()
  {
 super.onPreExecute();
 }

  protected void onPostExecute(String result)
 {
 super.onPostExecute(result);
  }
 }

 public class MyLocationList implements LocationListener
  {

 public void onLocationChanged(Location arg0)
 {
  // TODO Auto-generated method stub
 UpdateWithNewLocation(arg0);
 }

 public void onProviderDisabled(String provider)
 {
 // TODO Auto-generated method stub
  Toast.makeText(getApplicationContext(),GPS Disable ,
 Toast.LENGTH_LONG).show();
 }

  public void onProviderEnabled(String provider)
 {
 // TODO Auto-generated method stub
  Toast.makeText(getApplicationContext(),GPS enabled,
 Toast.LENGTH_LONG).show();
 }

  public void onStatusChanged(String provider, int status, Bundle extras)
 {
 // TODO Auto-generated method stub
  }
 }
 }


 On Fri, Oct 4, 2013 at 4:44 AM, Lew lewbl...@gmail.com wrote:

  HImanshu Mittal wrote:

 Bro , Don't dramatize things out here. I have asked a question thats it.


 How is asking for relevant details dramatizing it?

 It's spelled that's.


 For the first the first time I have asked a question on any forum
 regarding a help in my 8 months of development time.


 Not important.


 I was not able to make a code because the code which I have made is not
 working.


 That's like telling a doctor, I don't feel well and expecting a
 diagnosis. You need to provide details.


 If you can provide the code than it will be really be helpful or I can
 also post my code out here than you can tell me where I am doing it wrong



 :)


 Since that's what the guy was asking for, why do you give him a hard
 time?


 On Thu, Oct 3, 2013 at 9:23 PM, Steve Gabrilowitz 
 steve...@gmail.comwrote:

 You are more likely to get help developing your own service if tell us
 in which areas you have been less than successful.  If you are looking for
 a full piece of code already written for you then try 

Re: [android-developers] Re: How to make a Service That will periodically send the Users Location on a server

2013-10-04 Thread HImanshu Mittal
But when I open my map
And as i have done
maps.setmylocationenabled
than the blue dot comes at the position where I am
But the same doesn't come when I use it in my service
Thats y I was asking how to fix it !!!


On Fri, Oct 4, 2013 at 7:06 PM, Kristopher Micinski
krismicin...@gmail.comwrote:

 I guess the problem is, if your location is unavailable, how are you
 expecting that that will be fixed?  This doesn't make any sense, if it's
 not available, it's not available,

 Kris



 On Fri, Oct 4, 2013 at 6:16 AM, HImanshu Mittal himanshu5...@gmail.comwrote:

 Hello friends,
 I have just checked it out that my service is working fine but the
 problem is I am in an area where location is unavalaible and my friend is
 in an area where location is availaible.
 How should* *I fix this that my location also can be transmitted to my
 server!!!

 Now I think ii could be solved
 Please Help!!


 On Fri, Oct 4, 2013 at 9:47 AM, HImanshu Mittal 
 himanshu5...@gmail.comwrote:

 package com.example.metro;

 import com.dude5692.StaticURL.ProjectURL;

 import json.jSOn;

 import android.app.Service;
 import android.content.Context;
 import android.content.Intent;
 import android.content.SharedPreferences;
 import android.location.Criteria;
 import android.location.Location;
 import android.location.LocationListener;
 import android.location.LocationManager;
 import android.os.AsyncTask;
 import android.os.Bundle;
 import android.os.IBinder;
 import android.widget.Toast;

 public class MyService extends Service
 {
 ProjectURL proURL = new ProjectURL();
 String initialURL;
  SharedPreferences pref;

 @Override
 public void onCreate()
  {
 // TODO Auto-generated method stub
 super.onCreate();
  final LocationManager mlocmag =
 (LocationManager)getSystemService(Context.LOCATION_SERVICE);
 final LocationListener mlocList = new MyLocationList();

 Criteria criteria = new Criteria();

 // Getting the name of the best provider
  final String provider = mlocmag.getBestProvider(criteria, true);

 final Location loc = mlocmag.getLastKnownLocation(provider);
  UpdateWithNewLocation(loc); // This method is used to get updated
 location.
 mlocmag.requestLocationUpdates(provider, 1000, 0, mlocList);
  }

 @Override
 public IBinder onBind(Intent arg0)
  {
 // TODO Auto-generated method stub
 return null;
  }

 @Override
 public void onDestroy()
  {
 // TODO Auto-generated method stub
 super.onDestroy();
  }

 @Override
 public int onStartCommand(Intent intent, int flags, int startId)
  {
 // TODO Auto-generated method stub
 return super.onStartCommand(intent, flags, startId);
  }
 private void UpdateWithNewLocation(final Location loc)
 {
  // TODO Auto-generated method stub
 if(loc!= null)
 {
  final double lat =loc.getLatitude(); // Updated lat
 final double Long = loc.getLongitude(); // Updated long

 pref = getSharedPreferences(myMetroFile,Context.MODE_PRIVATE);
  System.out.println(MO   Service Running);
  String UniqueDeviceId = pref.getString(DeviceUniqueID, 0);
 initialURL = proURL.projectURL +
 storeLatLong.php?RegID=+lat+Email=+Long+Device=+UniqueDeviceId+Start=NO;
  new Async().execute();
 }
 else
 {
  }
 }

 class Async extends AsyncTaskString, Void, String
  {

 //ProgressDialog progress;

 protected String doInBackground(String... params)
  {
 try
 {
  new jSOn().execute(initialURL);
 }
 catch (Exception e)
  {
 e.printStackTrace();
 }
  return null;
 }

 protected void onPreExecute()
  {
 super.onPreExecute();
 }

  protected void onPostExecute(String result)
 {
 super.onPostExecute(result);
  }
 }

 public class MyLocationList implements LocationListener
  {

 public void onLocationChanged(Location arg0)
 {
  // TODO Auto-generated method stub
 UpdateWithNewLocation(arg0);
 }

 public void onProviderDisabled(String provider)
 {
 // TODO Auto-generated method stub
  Toast.makeText(getApplicationContext(),GPS Disable ,
 Toast.LENGTH_LONG).show();
 }

  public void onProviderEnabled(String provider)
 {
 // TODO Auto-generated method stub
  Toast.makeText(getApplicationContext(),GPS enabled,
 Toast.LENGTH_LONG).show();
 }

  public void onStatusChanged(String provider, int status, Bundle
 extras)
 {
 // TODO Auto-generated method stub
  }
 }
 }


 On Fri, Oct 4, 2013 at 4:44 AM, Lew lewbl...@gmail.com wrote:

  HImanshu Mittal wrote:

 Bro , Don't dramatize things out here. I have asked a question thats
 it.


 How is asking for relevant details dramatizing it?

 It's spelled that's.


 For the first the first time I have asked a question on any forum
 regarding a help in my 8 months of development time.


 Not important.


 I was not able to make a code because the code which I have made is
 not working.


 That's like telling a doctor, I don't feel well and expecting a
 diagnosis. You need to provide details.


 If you can provide the code than it will be really be helpful or I can
 also post my code out here than you can tell me where I am doing it wrong



 :)


 Since that's what the guy was asking for, why do you give 

Re: [android-developers] Re: How to make a Service That will periodically send the Users Location on a server

2013-10-04 Thread Mukesh Srivastav
The problem could be , Himanshu is missing the Location setting to be
enabled  :)

Please check the device setting and test your code.


On Fri, Oct 4, 2013 at 7:06 PM, Kristopher Micinski
krismicin...@gmail.comwrote:

 I guess the problem is, if your location is unavailable, how are you
 expecting that that will be fixed?  This doesn't make any sense, if it's
 not available, it's not available,

 Kris



 On Fri, Oct 4, 2013 at 6:16 AM, HImanshu Mittal himanshu5...@gmail.comwrote:

 Hello friends,
 I have just checked it out that my service is working fine but the
 problem is I am in an area where location is unavalaible and my friend is
 in an area where location is availaible.
 How should* *I fix this that my location also can be transmitted to my
 server!!!

 Now I think ii could be solved
 Please Help!!


 On Fri, Oct 4, 2013 at 9:47 AM, HImanshu Mittal 
 himanshu5...@gmail.comwrote:

 package com.example.metro;

 import com.dude5692.StaticURL.ProjectURL;

 import json.jSOn;

 import android.app.Service;
 import android.content.Context;
 import android.content.Intent;
 import android.content.SharedPreferences;
 import android.location.Criteria;
 import android.location.Location;
 import android.location.LocationListener;
 import android.location.LocationManager;
 import android.os.AsyncTask;
 import android.os.Bundle;
 import android.os.IBinder;
 import android.widget.Toast;

 public class MyService extends Service
 {
 ProjectURL proURL = new ProjectURL();
 String initialURL;
  SharedPreferences pref;

 @Override
 public void onCreate()
  {
 // TODO Auto-generated method stub
 super.onCreate();
  final LocationManager mlocmag =
 (LocationManager)getSystemService(Context.LOCATION_SERVICE);
 final LocationListener mlocList = new MyLocationList();

 Criteria criteria = new Criteria();

 // Getting the name of the best provider
  final String provider = mlocmag.getBestProvider(criteria, true);

 final Location loc = mlocmag.getLastKnownLocation(provider);
  UpdateWithNewLocation(loc); // This method is used to get updated
 location.
 mlocmag.requestLocationUpdates(provider, 1000, 0, mlocList);
  }

 @Override
 public IBinder onBind(Intent arg0)
  {
 // TODO Auto-generated method stub
 return null;
  }

 @Override
 public void onDestroy()
  {
 // TODO Auto-generated method stub
 super.onDestroy();
  }

 @Override
 public int onStartCommand(Intent intent, int flags, int startId)
  {
 // TODO Auto-generated method stub
 return super.onStartCommand(intent, flags, startId);
  }
 private void UpdateWithNewLocation(final Location loc)
 {
  // TODO Auto-generated method stub
 if(loc!= null)
 {
  final double lat =loc.getLatitude(); // Updated lat
 final double Long = loc.getLongitude(); // Updated long

 pref = getSharedPreferences(myMetroFile,Context.MODE_PRIVATE);
  System.out.println(MO   Service Running);
  String UniqueDeviceId = pref.getString(DeviceUniqueID, 0);
 initialURL = proURL.projectURL +
 storeLatLong.php?RegID=+lat+Email=+Long+Device=+UniqueDeviceId+Start=NO;
  new Async().execute();
 }
 else
 {
  }
 }

 class Async extends AsyncTaskString, Void, String
  {

 //ProgressDialog progress;

 protected String doInBackground(String... params)
  {
 try
 {
  new jSOn().execute(initialURL);
 }
 catch (Exception e)
  {
 e.printStackTrace();
 }
  return null;
 }

 protected void onPreExecute()
  {
 super.onPreExecute();
 }

  protected void onPostExecute(String result)
 {
 super.onPostExecute(result);
  }
 }

 public class MyLocationList implements LocationListener
  {

 public void onLocationChanged(Location arg0)
 {
  // TODO Auto-generated method stub
 UpdateWithNewLocation(arg0);
 }

 public void onProviderDisabled(String provider)
 {
 // TODO Auto-generated method stub
  Toast.makeText(getApplicationContext(),GPS Disable ,
 Toast.LENGTH_LONG).show();
 }

  public void onProviderEnabled(String provider)
 {
 // TODO Auto-generated method stub
  Toast.makeText(getApplicationContext(),GPS enabled,
 Toast.LENGTH_LONG).show();
 }

  public void onStatusChanged(String provider, int status, Bundle
 extras)
 {
 // TODO Auto-generated method stub
  }
 }
 }


 On Fri, Oct 4, 2013 at 4:44 AM, Lew lewbl...@gmail.com wrote:

  HImanshu Mittal wrote:

 Bro , Don't dramatize things out here. I have asked a question thats
 it.


 How is asking for relevant details dramatizing it?

 It's spelled that's.


 For the first the first time I have asked a question on any forum
 regarding a help in my 8 months of development time.


 Not important.


 I was not able to make a code because the code which I have made is
 not working.


 That's like telling a doctor, I don't feel well and expecting a
 diagnosis. You need to provide details.


 If you can provide the code than it will be really be helpful or I can
 also post my code out here than you can tell me where I am doing it wrong



 :)


 Since that's what the guy was asking for, why do you give him a hard
 time?


 On Thu, Oct 3, 2013 at 9:23 PM, Steve Gabrilowitz 
 

Re: [android-developers] Re: How to make a Service That will periodically send the Users Location on a server

2013-10-04 Thread HImanshu Mittal
I have enabled it ...
If it was not enabled the blue dot would not have appeared
But as the permissions are there it appears on the map !!!


On Fri, Oct 4, 2013 at 7:28 PM, Mukesh Srivastav mukicha...@gmail.comwrote:

 The problem could be , Himanshu is missing the Location setting to be
 enabled  :)

 Please check the device setting and test your code.


 On Fri, Oct 4, 2013 at 7:06 PM, Kristopher Micinski 
 krismicin...@gmail.com wrote:

 I guess the problem is, if your location is unavailable, how are you
 expecting that that will be fixed?  This doesn't make any sense, if it's
 not available, it's not available,

 Kris



 On Fri, Oct 4, 2013 at 6:16 AM, HImanshu Mittal 
 himanshu5...@gmail.comwrote:

 Hello friends,
 I have just checked it out that my service is working fine but the
 problem is I am in an area where location is unavalaible and my friend is
 in an area where location is availaible.
 How should* *I fix this that my location also can be transmitted to my
 server!!!

 Now I think ii could be solved
 Please Help!!


 On Fri, Oct 4, 2013 at 9:47 AM, HImanshu Mittal 
 himanshu5...@gmail.comwrote:

 package com.example.metro;

 import com.dude5692.StaticURL.ProjectURL;

 import json.jSOn;

 import android.app.Service;
 import android.content.Context;
 import android.content.Intent;
 import android.content.SharedPreferences;
 import android.location.Criteria;
 import android.location.Location;
 import android.location.LocationListener;
 import android.location.LocationManager;
 import android.os.AsyncTask;
 import android.os.Bundle;
 import android.os.IBinder;
 import android.widget.Toast;

 public class MyService extends Service
 {
 ProjectURL proURL = new ProjectURL();
 String initialURL;
  SharedPreferences pref;

 @Override
 public void onCreate()
  {
 // TODO Auto-generated method stub
 super.onCreate();
  final LocationManager mlocmag =
 (LocationManager)getSystemService(Context.LOCATION_SERVICE);
 final LocationListener mlocList = new MyLocationList();

 Criteria criteria = new Criteria();

 // Getting the name of the best provider
  final String provider = mlocmag.getBestProvider(criteria, true);

 final Location loc = mlocmag.getLastKnownLocation(provider);
  UpdateWithNewLocation(loc); // This method is used to get updated
 location.
 mlocmag.requestLocationUpdates(provider, 1000, 0, mlocList);
  }

 @Override
 public IBinder onBind(Intent arg0)
  {
 // TODO Auto-generated method stub
 return null;
  }

 @Override
 public void onDestroy()
  {
 // TODO Auto-generated method stub
 super.onDestroy();
  }

 @Override
 public int onStartCommand(Intent intent, int flags, int startId)
  {
 // TODO Auto-generated method stub
 return super.onStartCommand(intent, flags, startId);
  }
 private void UpdateWithNewLocation(final Location loc)
 {
  // TODO Auto-generated method stub
 if(loc!= null)
 {
  final double lat =loc.getLatitude(); // Updated lat
 final double Long = loc.getLongitude(); // Updated long

 pref = getSharedPreferences(myMetroFile,Context.MODE_PRIVATE);
  System.out.println(MO   Service Running);
  String UniqueDeviceId = pref.getString(DeviceUniqueID, 0);
 initialURL = proURL.projectURL +
 storeLatLong.php?RegID=+lat+Email=+Long+Device=+UniqueDeviceId+Start=NO;
  new Async().execute();
 }
 else
 {
  }
 }

 class Async extends AsyncTaskString, Void, String
  {

 //ProgressDialog progress;

 protected String doInBackground(String... params)
  {
 try
 {
  new jSOn().execute(initialURL);
 }
 catch (Exception e)
  {
 e.printStackTrace();
 }
  return null;
 }

 protected void onPreExecute()
  {
 super.onPreExecute();
 }

  protected void onPostExecute(String result)
 {
 super.onPostExecute(result);
  }
 }

 public class MyLocationList implements LocationListener
  {

 public void onLocationChanged(Location arg0)
 {
  // TODO Auto-generated method stub
 UpdateWithNewLocation(arg0);
 }

 public void onProviderDisabled(String provider)
 {
 // TODO Auto-generated method stub
  Toast.makeText(getApplicationContext(),GPS Disable ,
 Toast.LENGTH_LONG).show();
 }

  public void onProviderEnabled(String provider)
 {
 // TODO Auto-generated method stub
  Toast.makeText(getApplicationContext(),GPS enabled,
 Toast.LENGTH_LONG).show();
 }

  public void onStatusChanged(String provider, int status, Bundle
 extras)
 {
 // TODO Auto-generated method stub
  }
 }
 }


 On Fri, Oct 4, 2013 at 4:44 AM, Lew lewbl...@gmail.com wrote:

  HImanshu Mittal wrote:

 Bro , Don't dramatize things out here. I have asked a question thats
 it.


 How is asking for relevant details dramatizing it?

 It's spelled that's.


 For the first the first time I have asked a question on any forum
 regarding a help in my 8 months of development time.


 Not important.


 I was not able to make a code because the code which I have made is
 not working.


 That's like telling a doctor, I don't feel well and expecting a
 diagnosis. You need to provide details.


 If you can provide the code than it will be really be 

Re: [android-developers] Re: How to make a Service That will periodically send the Users Location on a server

2013-10-04 Thread Mukesh Srivastav
Look, you are only checking for the best location but, I would suggest to
check all the possibilities.

Please try the below code
public Location getLocation() {
try {
locationManager = (LocationManager) this
.getSystemService(LOCATION_SERVICE);

// getting GPS status
isGPSEnabled = locationManager
.isProviderEnabled(LocationManager.GPS_PROVIDER);

// getting network status
isNetworkEnabled = locationManager
.isProviderEnabled(LocationManager.NETWORK_PROVIDER);

if (!isGPSEnabled  !isNetworkEnabled) {
// no network provider is enabled
} else {
LocationListener mlocListener = new GPSListener(parentcontext);
this.canGetLocation = true;
if (isNetworkEnabled) {
locationManager.requestLocationUpdates(
LocationManager.NETWORK_PROVIDER,
MIN_TIME_BW_UPDATES,
MIN_DISTANCE_CHANGE_FOR_UPDATES, mlocListener);
Log.d(Network, Network Enabled);
if (locationManager != null) {
location = locationManager
.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
if (location != null) {
latitude = location.getLatitude();
longitude = location.getLongitude();
PalsApplication.glatitude = latitude;
PalsApplication.glongitude = longitude;
}
}
}
// if GPS Enabled get lat/long using GPS Services
if (isGPSEnabled) {
if (location == null) {
locationManager.requestLocationUpdates(
LocationManager.GPS_PROVIDER,
MIN_TIME_BW_UPDATES,
MIN_DISTANCE_CHANGE_FOR_UPDATES, mlocListener);
Log.d(GPS, GPS Enabled);
if (locationManager != null) {
location = locationManager
.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (location != null) {
latitude = location.getLatitude();
longitude = location.getLongitude();
PalsApplication.glatitude = latitude;
PalsApplication.glongitude = longitude;
}
}
}
}
}

} catch (Exception e) {
e.printStackTrace();
}

return location;
}



On Fri, Oct 4, 2013 at 7:28 PM, HImanshu Mittal himanshu5...@gmail.comwrote:

 But when I open my map
 And as i have done
 maps.setmylocationenabled
 than the blue dot comes at the position where I am
 But the same doesn't come when I use it in my service
 Thats y I was asking how to fix it !!!


 On Fri, Oct 4, 2013 at 7:06 PM, Kristopher Micinski 
 krismicin...@gmail.com wrote:

 I guess the problem is, if your location is unavailable, how are you
 expecting that that will be fixed?  This doesn't make any sense, if it's
 not available, it's not available,

 Kris



 On Fri, Oct 4, 2013 at 6:16 AM, HImanshu Mittal 
 himanshu5...@gmail.comwrote:

 Hello friends,
 I have just checked it out that my service is working fine but the
 problem is I am in an area where location is unavalaible and my friend is
 in an area where location is availaible.
 How should* *I fix this that my location also can be transmitted to my
 server!!!

 Now I think ii could be solved
 Please Help!!


 On Fri, Oct 4, 2013 at 9:47 AM, HImanshu Mittal 
 himanshu5...@gmail.comwrote:

 package com.example.metro;

 import com.dude5692.StaticURL.ProjectURL;

 import json.jSOn;

 import android.app.Service;
 import android.content.Context;
 import android.content.Intent;
 import android.content.SharedPreferences;
 import android.location.Criteria;
 import android.location.Location;
 import android.location.LocationListener;
 import android.location.LocationManager;
 import android.os.AsyncTask;
 import android.os.Bundle;
 import android.os.IBinder;
 import android.widget.Toast;

 public class MyService extends Service
 {
 ProjectURL proURL = new ProjectURL();
 String initialURL;
  SharedPreferences pref;

 @Override
 public void onCreate()
  {
 // TODO Auto-generated method stub
 super.onCreate();
  final LocationManager mlocmag =
 (LocationManager)getSystemService(Context.LOCATION_SERVICE);
 final LocationListener mlocList = new MyLocationList();

 Criteria criteria = new Criteria();

 // Getting the name of the best provider
  final String provider = mlocmag.getBestProvider(criteria, true);

 final Location loc = mlocmag.getLastKnownLocation(provider);
  UpdateWithNewLocation(loc); // This method is used to get updated
 location.
 mlocmag.requestLocationUpdates(provider, 1000, 0, mlocList);
  }

 @Override
 public IBinder onBind(Intent arg0)
  {
 // TODO Auto-generated method stub
 return null;
  }

 @Override
 public void onDestroy()
  {
 // TODO Auto-generated method stub
 super.onDestroy();
  }

 @Override
 public int onStartCommand(Intent intent, int flags, int startId)
  {
 // TODO Auto-generated method stub
 return super.onStartCommand(intent, flags, startId);
  }
 private void UpdateWithNewLocation(final Location loc)
 {
  // TODO Auto-generated method stub
 if(loc!= null)
 {
  final double lat =loc.getLatitude(); // Updated lat
 final double Long = loc.getLongitude(); // Updated long

 pref = getSharedPreferences(myMetroFile,Context.MODE_PRIVATE);
  System.out.println(MO   Service Running);
  String UniqueDeviceId = pref.getString(DeviceUniqueID, 0);
 initialURL = proURL.projectURL +
 storeLatLong.php?RegID=+lat+Email=+Long+Device=+UniqueDeviceId+Start=NO;
  new Async().execute();
 }
 else
 {
  }
 }

 

Re: [android-developers] Re: How to make a Service That will periodically send the Users Location on a server

2013-10-04 Thread Mukesh Srivastav
I think, you have missed the code which i had sent you... check that


On Fri, Oct 4, 2013 at 7:40 PM, HImanshu Mittal himanshu5...@gmail.comwrote:

 I have enabled it ...
 If it was not enabled the blue dot would not have appeared
 But as the permissions are there it appears on the map !!!


 On Fri, Oct 4, 2013 at 7:28 PM, Mukesh Srivastav mukicha...@gmail.comwrote:

 The problem could be , Himanshu is missing the Location setting to be
 enabled  :)

 Please check the device setting and test your code.


  On Fri, Oct 4, 2013 at 7:06 PM, Kristopher Micinski 
 krismicin...@gmail.com wrote:

 I guess the problem is, if your location is unavailable, how are you
 expecting that that will be fixed?  This doesn't make any sense, if it's
 not available, it's not available,

 Kris



 On Fri, Oct 4, 2013 at 6:16 AM, HImanshu Mittal 
 himanshu5...@gmail.comwrote:

 Hello friends,
 I have just checked it out that my service is working fine but the
 problem is I am in an area where location is unavalaible and my friend is
 in an area where location is availaible.
 How should* *I fix this that my location also can be transmitted to my
 server!!!

 Now I think ii could be solved
 Please Help!!


 On Fri, Oct 4, 2013 at 9:47 AM, HImanshu Mittal himanshu5...@gmail.com
  wrote:

 package com.example.metro;

 import com.dude5692.StaticURL.ProjectURL;

 import json.jSOn;

 import android.app.Service;
 import android.content.Context;
 import android.content.Intent;
 import android.content.SharedPreferences;
 import android.location.Criteria;
 import android.location.Location;
 import android.location.LocationListener;
 import android.location.LocationManager;
 import android.os.AsyncTask;
 import android.os.Bundle;
 import android.os.IBinder;
 import android.widget.Toast;

 public class MyService extends Service
 {
 ProjectURL proURL = new ProjectURL();
 String initialURL;
  SharedPreferences pref;

 @Override
 public void onCreate()
  {
 // TODO Auto-generated method stub
 super.onCreate();
  final LocationManager mlocmag =
 (LocationManager)getSystemService(Context.LOCATION_SERVICE);
 final LocationListener mlocList = new MyLocationList();

 Criteria criteria = new Criteria();

 // Getting the name of the best provider
  final String provider = mlocmag.getBestProvider(criteria, true);

 final Location loc = mlocmag.getLastKnownLocation(provider);
  UpdateWithNewLocation(loc); // This method is used to get updated
 location.
 mlocmag.requestLocationUpdates(provider, 1000, 0, mlocList);
  }

 @Override
 public IBinder onBind(Intent arg0)
  {
 // TODO Auto-generated method stub
 return null;
  }

 @Override
 public void onDestroy()
  {
 // TODO Auto-generated method stub
 super.onDestroy();
  }

 @Override
 public int onStartCommand(Intent intent, int flags, int startId)
  {
 // TODO Auto-generated method stub
 return super.onStartCommand(intent, flags, startId);
  }
 private void UpdateWithNewLocation(final Location loc)
 {
  // TODO Auto-generated method stub
 if(loc!= null)
 {
  final double lat =loc.getLatitude(); // Updated lat
 final double Long = loc.getLongitude(); // Updated long

 pref = getSharedPreferences(myMetroFile,Context.MODE_PRIVATE);
  System.out.println(MO   Service Running);
  String UniqueDeviceId = pref.getString(DeviceUniqueID, 0);
 initialURL = proURL.projectURL +
 storeLatLong.php?RegID=+lat+Email=+Long+Device=+UniqueDeviceId+Start=NO;
  new Async().execute();
 }
 else
 {
  }
 }

 class Async extends AsyncTaskString, Void, String
  {

 //ProgressDialog progress;

 protected String doInBackground(String... params)
  {
 try
 {
  new jSOn().execute(initialURL);
 }
 catch (Exception e)
  {
 e.printStackTrace();
 }
  return null;
 }

 protected void onPreExecute()
  {
 super.onPreExecute();
 }

  protected void onPostExecute(String result)
 {
 super.onPostExecute(result);
  }
 }

 public class MyLocationList implements LocationListener
  {

 public void onLocationChanged(Location arg0)
 {
  // TODO Auto-generated method stub
 UpdateWithNewLocation(arg0);
 }

 public void onProviderDisabled(String provider)
 {
 // TODO Auto-generated method stub
  Toast.makeText(getApplicationContext(),GPS Disable ,
 Toast.LENGTH_LONG).show();
 }

  public void onProviderEnabled(String provider)
 {
 // TODO Auto-generated method stub
  Toast.makeText(getApplicationContext(),GPS enabled,
 Toast.LENGTH_LONG).show();
 }

  public void onStatusChanged(String provider, int status, Bundle
 extras)
 {
 // TODO Auto-generated method stub
  }
 }
 }


 On Fri, Oct 4, 2013 at 4:44 AM, Lew lewbl...@gmail.com wrote:

  HImanshu Mittal wrote:

 Bro , Don't dramatize things out here. I have asked a question thats
 it.


 How is asking for relevant details dramatizing it?

 It's spelled that's.


 For the first the first time I have asked a question on any forum
 regarding a help in my 8 months of development time.


 Not important.


 I was not able to make a code because the code which I have made is
 not working.


 That's like 

Re: [android-developers] Re: How to make a Service That will periodically send the Users Location on a server

2013-10-04 Thread HImanshu Mittal
but the requestLocationUpdates can be passed with any one provider I guess
and the Service will take one think particularly and will poll location
based on that instant only !!!


On Fri, Oct 4, 2013 at 7:43 PM, Mukesh Srivastav mukicha...@gmail.comwrote:

 Look, you are only checking for the best location but, I would suggest to
 check all the possibilities.

 Please try the below code
 public Location getLocation() {
  try {
 locationManager = (LocationManager) this
 .getSystemService(LOCATION_SERVICE);

 // getting GPS status
 isGPSEnabled = locationManager
 .isProviderEnabled(LocationManager.GPS_PROVIDER);

 // getting network status
 isNetworkEnabled = locationManager
 .isProviderEnabled(LocationManager.NETWORK_PROVIDER);

 if (!isGPSEnabled  !isNetworkEnabled) {
 // no network provider is enabled
  } else {
 LocationListener mlocListener = new GPSListener(parentcontext);
 this.canGetLocation = true;
  if (isNetworkEnabled) {
 locationManager.requestLocationUpdates(
 LocationManager.NETWORK_PROVIDER,
  MIN_TIME_BW_UPDATES,
 MIN_DISTANCE_CHANGE_FOR_UPDATES, mlocListener);
 Log.d(Network, Network Enabled);
  if (locationManager != null) {
 location = locationManager
 .getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
  if (location != null) {
 latitude = location.getLatitude();
 longitude = location.getLongitude();
  PalsApplication.glatitude = latitude;
 PalsApplication.glongitude = longitude;
 }
  }
 }
 // if GPS Enabled get lat/long using GPS Services
  if (isGPSEnabled) {
 if (location == null) {
 locationManager.requestLocationUpdates(
  LocationManager.GPS_PROVIDER,
 MIN_TIME_BW_UPDATES,
 MIN_DISTANCE_CHANGE_FOR_UPDATES, mlocListener);
  Log.d(GPS, GPS Enabled);
 if (locationManager != null) {
 location = locationManager
  .getLastKnownLocation(LocationManager.GPS_PROVIDER);
 if (location != null) {
 latitude = location.getLatitude();
  longitude = location.getLongitude();
 PalsApplication.glatitude = latitude;
 PalsApplication.glongitude = longitude;
  }
 }
 }
 }
  }

 } catch (Exception e) {
 e.printStackTrace();
  }

 return location;
 }



 On Fri, Oct 4, 2013 at 7:28 PM, HImanshu Mittal himanshu5...@gmail.comwrote:

 But when I open my map
 And as i have done
 maps.setmylocationenabled
 than the blue dot comes at the position where I am
 But the same doesn't come when I use it in my service
 Thats y I was asking how to fix it !!!


 On Fri, Oct 4, 2013 at 7:06 PM, Kristopher Micinski 
 krismicin...@gmail.com wrote:

 I guess the problem is, if your location is unavailable, how are you
 expecting that that will be fixed?  This doesn't make any sense, if it's
 not available, it's not available,

 Kris



 On Fri, Oct 4, 2013 at 6:16 AM, HImanshu Mittal 
 himanshu5...@gmail.comwrote:

 Hello friends,
 I have just checked it out that my service is working fine but the
 problem is I am in an area where location is unavalaible and my friend is
 in an area where location is availaible.
 How should* *I fix this that my location also can be transmitted to my
 server!!!

 Now I think ii could be solved
 Please Help!!


 On Fri, Oct 4, 2013 at 9:47 AM, HImanshu Mittal himanshu5...@gmail.com
  wrote:

 package com.example.metro;

 import com.dude5692.StaticURL.ProjectURL;

 import json.jSOn;

 import android.app.Service;
 import android.content.Context;
 import android.content.Intent;
 import android.content.SharedPreferences;
 import android.location.Criteria;
 import android.location.Location;
 import android.location.LocationListener;
 import android.location.LocationManager;
 import android.os.AsyncTask;
 import android.os.Bundle;
 import android.os.IBinder;
 import android.widget.Toast;

 public class MyService extends Service
 {
 ProjectURL proURL = new ProjectURL();
 String initialURL;
  SharedPreferences pref;

 @Override
 public void onCreate()
  {
 // TODO Auto-generated method stub
 super.onCreate();
  final LocationManager mlocmag =
 (LocationManager)getSystemService(Context.LOCATION_SERVICE);
 final LocationListener mlocList = new MyLocationList();

 Criteria criteria = new Criteria();

 // Getting the name of the best provider
  final String provider = mlocmag.getBestProvider(criteria, true);

 final Location loc = mlocmag.getLastKnownLocation(provider);
  UpdateWithNewLocation(loc); // This method is used to get updated
 location.
 mlocmag.requestLocationUpdates(provider, 1000, 0, mlocList);
  }

 @Override
 public IBinder onBind(Intent arg0)
  {
 // TODO Auto-generated method stub
 return null;
  }

 @Override
 public void onDestroy()
  {
 // TODO Auto-generated method stub
 super.onDestroy();
  }

 @Override
 public int onStartCommand(Intent intent, int flags, int startId)
  {
 // TODO Auto-generated method stub
 return super.onStartCommand(intent, flags, startId);
  }
 private void UpdateWithNewLocation(final Location loc)
 {
  // TODO Auto-generated method stub
 if(loc!= null)
 {
  final double lat =loc.getLatitude(); // Updated lat
 final double Long = loc.getLongitude(); // 

Re: [android-developers] Re: How to make a Service That will periodically send the Users Location on a server

2013-10-04 Thread HImanshu Mittal
Sir,
Actually, I don't know where this code has to be integrated in my code.
And that's why confused, IF you tell me that ,
I would test it right away and tell the update!!


On Fri, Oct 4, 2013 at 7:52 PM, Mukesh Srivastav mukicha...@gmail.comwrote:

 I think, you have missed the code which i had sent you... check that


 On Fri, Oct 4, 2013 at 7:40 PM, HImanshu Mittal himanshu5...@gmail.comwrote:

 I have enabled it ...
 If it was not enabled the blue dot would not have appeared
 But as the permissions are there it appears on the map !!!


 On Fri, Oct 4, 2013 at 7:28 PM, Mukesh Srivastav mukicha...@gmail.comwrote:

 The problem could be , Himanshu is missing the Location setting to be
 enabled  :)

 Please check the device setting and test your code.


  On Fri, Oct 4, 2013 at 7:06 PM, Kristopher Micinski 
 krismicin...@gmail.com wrote:

 I guess the problem is, if your location is unavailable, how are you
 expecting that that will be fixed?  This doesn't make any sense, if it's
 not available, it's not available,

 Kris



 On Fri, Oct 4, 2013 at 6:16 AM, HImanshu Mittal himanshu5...@gmail.com
  wrote:

 Hello friends,
 I have just checked it out that my service is working fine but the
 problem is I am in an area where location is unavalaible and my friend is
 in an area where location is availaible.
 How should* *I fix this that my location also can be transmitted to
 my server!!!

 Now I think ii could be solved
 Please Help!!


 On Fri, Oct 4, 2013 at 9:47 AM, HImanshu Mittal 
 himanshu5...@gmail.com wrote:

 package com.example.metro;

 import com.dude5692.StaticURL.ProjectURL;

 import json.jSOn;

 import android.app.Service;
 import android.content.Context;
 import android.content.Intent;
 import android.content.SharedPreferences;
 import android.location.Criteria;
 import android.location.Location;
 import android.location.LocationListener;
 import android.location.LocationManager;
 import android.os.AsyncTask;
 import android.os.Bundle;
 import android.os.IBinder;
 import android.widget.Toast;

 public class MyService extends Service
 {
 ProjectURL proURL = new ProjectURL();
 String initialURL;
  SharedPreferences pref;

 @Override
 public void onCreate()
  {
 // TODO Auto-generated method stub
 super.onCreate();
  final LocationManager mlocmag =
 (LocationManager)getSystemService(Context.LOCATION_SERVICE);
 final LocationListener mlocList = new MyLocationList();

 Criteria criteria = new Criteria();

 // Getting the name of the best provider
  final String provider = mlocmag.getBestProvider(criteria, true);

 final Location loc = mlocmag.getLastKnownLocation(provider);
  UpdateWithNewLocation(loc); // This method is used to get updated
 location.
 mlocmag.requestLocationUpdates(provider, 1000, 0, mlocList);
  }

 @Override
 public IBinder onBind(Intent arg0)
  {
 // TODO Auto-generated method stub
 return null;
  }

 @Override
 public void onDestroy()
  {
 // TODO Auto-generated method stub
 super.onDestroy();
  }

 @Override
 public int onStartCommand(Intent intent, int flags, int startId)
  {
 // TODO Auto-generated method stub
 return super.onStartCommand(intent, flags, startId);
  }
 private void UpdateWithNewLocation(final Location loc)
 {
  // TODO Auto-generated method stub
 if(loc!= null)
 {
  final double lat =loc.getLatitude(); // Updated lat
 final double Long = loc.getLongitude(); // Updated long

 pref = getSharedPreferences(myMetroFile,Context.MODE_PRIVATE);
  System.out.println(MO   Service Running);
  String UniqueDeviceId = pref.getString(DeviceUniqueID, 0);
 initialURL = proURL.projectURL +
 storeLatLong.php?RegID=+lat+Email=+Long+Device=+UniqueDeviceId+Start=NO;
  new Async().execute();
 }
 else
 {
  }
 }

 class Async extends AsyncTaskString, Void, String
  {

 //ProgressDialog progress;

 protected String doInBackground(String... params)
  {
 try
 {
  new jSOn().execute(initialURL);
 }
 catch (Exception e)
  {
 e.printStackTrace();
 }
  return null;
 }

 protected void onPreExecute()
  {
 super.onPreExecute();
 }

  protected void onPostExecute(String result)
 {
 super.onPostExecute(result);
  }
 }

 public class MyLocationList implements LocationListener
  {

 public void onLocationChanged(Location arg0)
 {
  // TODO Auto-generated method stub
 UpdateWithNewLocation(arg0);
 }

 public void onProviderDisabled(String provider)
 {
 // TODO Auto-generated method stub
  Toast.makeText(getApplicationContext(),GPS Disable ,
 Toast.LENGTH_LONG).show();
 }

  public void onProviderEnabled(String provider)
 {
 // TODO Auto-generated method stub
  Toast.makeText(getApplicationContext(),GPS enabled,
 Toast.LENGTH_LONG).show();
 }

  public void onStatusChanged(String provider, int status, Bundle
 extras)
 {
 // TODO Auto-generated method stub
  }
 }
 }


 On Fri, Oct 4, 2013 at 4:44 AM, Lew lewbl...@gmail.com wrote:

  HImanshu Mittal wrote:

 Bro , Don't dramatize things out here. I have asked a question
 thats it.


 How is asking for relevant details dramatizing it?

 It's 

Re: [android-developers] Re: How to make a Service That will periodically send the Users Location on a server

2013-10-04 Thread Mukesh Srivastav
I am out of this Forum :(


On Fri, Oct 4, 2013 at 7:57 PM, HImanshu Mittal himanshu5...@gmail.comwrote:

 but the requestLocationUpdates can be passed with any one provider I guess
 and the Service will take one think particularly and will poll location
 based on that instant only !!!


 On Fri, Oct 4, 2013 at 7:43 PM, Mukesh Srivastav mukicha...@gmail.comwrote:

 Look, you are only checking for the best location but, I would suggest to
 check all the possibilities.

 Please try the below code
 public Location getLocation() {
  try {
 locationManager = (LocationManager) this
 .getSystemService(LOCATION_SERVICE);

 // getting GPS status
 isGPSEnabled = locationManager
 .isProviderEnabled(LocationManager.GPS_PROVIDER);

 // getting network status
 isNetworkEnabled = locationManager
 .isProviderEnabled(LocationManager.NETWORK_PROVIDER);

 if (!isGPSEnabled  !isNetworkEnabled) {
 // no network provider is enabled
  } else {
 LocationListener mlocListener = new GPSListener(parentcontext);
 this.canGetLocation = true;
  if (isNetworkEnabled) {
 locationManager.requestLocationUpdates(
 LocationManager.NETWORK_PROVIDER,
  MIN_TIME_BW_UPDATES,
 MIN_DISTANCE_CHANGE_FOR_UPDATES, mlocListener);
 Log.d(Network, Network Enabled);
  if (locationManager != null) {
 location = locationManager
 .getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
  if (location != null) {
 latitude = location.getLatitude();
 longitude = location.getLongitude();
  PalsApplication.glatitude = latitude;
 PalsApplication.glongitude = longitude;
 }
  }
 }
 // if GPS Enabled get lat/long using GPS Services
  if (isGPSEnabled) {
 if (location == null) {
 locationManager.requestLocationUpdates(
  LocationManager.GPS_PROVIDER,
 MIN_TIME_BW_UPDATES,
 MIN_DISTANCE_CHANGE_FOR_UPDATES, mlocListener);
  Log.d(GPS, GPS Enabled);
 if (locationManager != null) {
 location = locationManager
  .getLastKnownLocation(LocationManager.GPS_PROVIDER);
 if (location != null) {
 latitude = location.getLatitude();
  longitude = location.getLongitude();
 PalsApplication.glatitude = latitude;
 PalsApplication.glongitude = longitude;
  }
 }
 }
 }
  }

 } catch (Exception e) {
 e.printStackTrace();
  }

 return location;
 }



 On Fri, Oct 4, 2013 at 7:28 PM, HImanshu Mittal 
 himanshu5...@gmail.comwrote:

 But when I open my map
 And as i have done
 maps.setmylocationenabled
 than the blue dot comes at the position where I am
 But the same doesn't come when I use it in my service
 Thats y I was asking how to fix it !!!


 On Fri, Oct 4, 2013 at 7:06 PM, Kristopher Micinski 
 krismicin...@gmail.com wrote:

 I guess the problem is, if your location is unavailable, how are you
 expecting that that will be fixed?  This doesn't make any sense, if it's
 not available, it's not available,

 Kris



 On Fri, Oct 4, 2013 at 6:16 AM, HImanshu Mittal himanshu5...@gmail.com
  wrote:

 Hello friends,
 I have just checked it out that my service is working fine but the
 problem is I am in an area where location is unavalaible and my friend is
 in an area where location is availaible.
 How should* *I fix this that my location also can be transmitted to
 my server!!!

 Now I think ii could be solved
 Please Help!!


 On Fri, Oct 4, 2013 at 9:47 AM, HImanshu Mittal 
 himanshu5...@gmail.com wrote:

 package com.example.metro;

 import com.dude5692.StaticURL.ProjectURL;

 import json.jSOn;

 import android.app.Service;
 import android.content.Context;
 import android.content.Intent;
 import android.content.SharedPreferences;
 import android.location.Criteria;
 import android.location.Location;
 import android.location.LocationListener;
 import android.location.LocationManager;
 import android.os.AsyncTask;
 import android.os.Bundle;
 import android.os.IBinder;
 import android.widget.Toast;

 public class MyService extends Service
 {
 ProjectURL proURL = new ProjectURL();
 String initialURL;
  SharedPreferences pref;

 @Override
 public void onCreate()
  {
 // TODO Auto-generated method stub
 super.onCreate();
  final LocationManager mlocmag =
 (LocationManager)getSystemService(Context.LOCATION_SERVICE);
 final LocationListener mlocList = new MyLocationList();

 Criteria criteria = new Criteria();

 // Getting the name of the best provider
  final String provider = mlocmag.getBestProvider(criteria, true);

 final Location loc = mlocmag.getLastKnownLocation(provider);
  UpdateWithNewLocation(loc); // This method is used to get updated
 location.
 mlocmag.requestLocationUpdates(provider, 1000, 0, mlocList);
  }

 @Override
 public IBinder onBind(Intent arg0)
  {
 // TODO Auto-generated method stub
 return null;
  }

 @Override
 public void onDestroy()
  {
 // TODO Auto-generated method stub
 super.onDestroy();
  }

 @Override
 public int onStartCommand(Intent intent, int flags, int startId)
  {
 // TODO Auto-generated method stub
 return super.onStartCommand(intent, flags, startId);
  }
 private void UpdateWithNewLocation(final Location loc)
 {
  // TODO Auto-generated method stub
 

Re: [android-developers] Re: How to make a Service That will periodically send the Users Location on a server

2013-10-04 Thread Mukesh Srivastav
sorry to say, you looks like collecting the code from here and there and
making your application.  :(

cant do the spoon feeding

sorry.


On Fri, Oct 4, 2013 at 8:08 PM, HImanshu Mittal himanshu5...@gmail.comwrote:

 Sir,
 Actually, I don't know where this code has to be integrated in my code.
 And that's why confused, IF you tell me that ,
 I would test it right away and tell the update!!


 On Fri, Oct 4, 2013 at 7:52 PM, Mukesh Srivastav mukicha...@gmail.comwrote:

 I think, you have missed the code which i had sent you... check that


 On Fri, Oct 4, 2013 at 7:40 PM, HImanshu Mittal 
 himanshu5...@gmail.comwrote:

 I have enabled it ...
 If it was not enabled the blue dot would not have appeared
 But as the permissions are there it appears on the map !!!


 On Fri, Oct 4, 2013 at 7:28 PM, Mukesh Srivastav 
 mukicha...@gmail.comwrote:

 The problem could be , Himanshu is missing the Location setting to be
 enabled  :)

 Please check the device setting and test your code.


  On Fri, Oct 4, 2013 at 7:06 PM, Kristopher Micinski 
 krismicin...@gmail.com wrote:

 I guess the problem is, if your location is unavailable, how are you
 expecting that that will be fixed?  This doesn't make any sense, if it's
 not available, it's not available,

 Kris



 On Fri, Oct 4, 2013 at 6:16 AM, HImanshu Mittal 
 himanshu5...@gmail.com wrote:

 Hello friends,
 I have just checked it out that my service is working fine but the
 problem is I am in an area where location is unavalaible and my friend is
 in an area where location is availaible.
 How should* *I fix this that my location also can be transmitted to
 my server!!!

 Now I think ii could be solved
 Please Help!!


 On Fri, Oct 4, 2013 at 9:47 AM, HImanshu Mittal 
 himanshu5...@gmail.com wrote:

 package com.example.metro;

 import com.dude5692.StaticURL.ProjectURL;

 import json.jSOn;

 import android.app.Service;
 import android.content.Context;
 import android.content.Intent;
 import android.content.SharedPreferences;
 import android.location.Criteria;
 import android.location.Location;
 import android.location.LocationListener;
 import android.location.LocationManager;
 import android.os.AsyncTask;
 import android.os.Bundle;
 import android.os.IBinder;
 import android.widget.Toast;

 public class MyService extends Service
 {
 ProjectURL proURL = new ProjectURL();
 String initialURL;
  SharedPreferences pref;

 @Override
 public void onCreate()
  {
 // TODO Auto-generated method stub
 super.onCreate();
  final LocationManager mlocmag =
 (LocationManager)getSystemService(Context.LOCATION_SERVICE);
 final LocationListener mlocList = new MyLocationList();

 Criteria criteria = new Criteria();

 // Getting the name of the best provider
  final String provider = mlocmag.getBestProvider(criteria, true);

 final Location loc = mlocmag.getLastKnownLocation(provider);
  UpdateWithNewLocation(loc); // This method is used to get updated
 location.
 mlocmag.requestLocationUpdates(provider, 1000, 0, mlocList);
  }

 @Override
 public IBinder onBind(Intent arg0)
  {
 // TODO Auto-generated method stub
 return null;
  }

 @Override
 public void onDestroy()
  {
 // TODO Auto-generated method stub
 super.onDestroy();
  }

 @Override
 public int onStartCommand(Intent intent, int flags, int startId)
  {
 // TODO Auto-generated method stub
 return super.onStartCommand(intent, flags, startId);
  }
 private void UpdateWithNewLocation(final Location loc)
 {
  // TODO Auto-generated method stub
 if(loc!= null)
 {
  final double lat =loc.getLatitude(); // Updated lat
 final double Long = loc.getLongitude(); // Updated long

 pref = getSharedPreferences(myMetroFile,Context.MODE_PRIVATE);
  System.out.println(MO   Service Running);
  String UniqueDeviceId = pref.getString(DeviceUniqueID, 0);
 initialURL = proURL.projectURL +
 storeLatLong.php?RegID=+lat+Email=+Long+Device=+UniqueDeviceId+Start=NO;
  new Async().execute();
 }
 else
 {
  }
 }

 class Async extends AsyncTaskString, Void, String
  {

 //ProgressDialog progress;

 protected String doInBackground(String... params)
  {
 try
 {
  new jSOn().execute(initialURL);
 }
 catch (Exception e)
  {
 e.printStackTrace();
 }
  return null;
 }

 protected void onPreExecute()
  {
 super.onPreExecute();
 }

  protected void onPostExecute(String result)
 {
 super.onPostExecute(result);
  }
 }

 public class MyLocationList implements LocationListener
  {

 public void onLocationChanged(Location arg0)
 {
  // TODO Auto-generated method stub
 UpdateWithNewLocation(arg0);
 }

 public void onProviderDisabled(String provider)
 {
 // TODO Auto-generated method stub
  Toast.makeText(getApplicationContext(),GPS Disable ,
 Toast.LENGTH_LONG).show();
 }

  public void onProviderEnabled(String provider)
 {
 // TODO Auto-generated method stub
  Toast.makeText(getApplicationContext(),GPS enabled,
 Toast.LENGTH_LONG).show();
 }

  public void onStatusChanged(String provider, int status, Bundle
 extras)
 {
 // TODO Auto-generated method stub
  

Re: [android-developers] Re: How to make a Service That will periodically send the Users Location on a server

2013-10-04 Thread HImanshu Mittal
No problem Sir,
I will figure it out Soon!!!

And thanx once again!! :)


On Fri, Oct 4, 2013 at 8:34 PM, Mukesh Srivastav mukicha...@gmail.comwrote:

 sorry to say, you looks like collecting the code from here and there and
 making your application.  :(

 cant do the spoon feeding

 sorry.


 On Fri, Oct 4, 2013 at 8:08 PM, HImanshu Mittal himanshu5...@gmail.comwrote:

 Sir,
 Actually, I don't know where this code has to be integrated in my code.
 And that's why confused, IF you tell me that ,
 I would test it right away and tell the update!!


 On Fri, Oct 4, 2013 at 7:52 PM, Mukesh Srivastav mukicha...@gmail.comwrote:

 I think, you have missed the code which i had sent you... check that


 On Fri, Oct 4, 2013 at 7:40 PM, HImanshu Mittal 
 himanshu5...@gmail.comwrote:

 I have enabled it ...
 If it was not enabled the blue dot would not have appeared
 But as the permissions are there it appears on the map !!!


 On Fri, Oct 4, 2013 at 7:28 PM, Mukesh Srivastav 
 mukicha...@gmail.comwrote:

 The problem could be , Himanshu is missing the Location setting to be
 enabled  :)

 Please check the device setting and test your code.


  On Fri, Oct 4, 2013 at 7:06 PM, Kristopher Micinski 
 krismicin...@gmail.com wrote:

 I guess the problem is, if your location is unavailable, how are you
 expecting that that will be fixed?  This doesn't make any sense, if it's
 not available, it's not available,

 Kris



 On Fri, Oct 4, 2013 at 6:16 AM, HImanshu Mittal 
 himanshu5...@gmail.com wrote:

 Hello friends,
 I have just checked it out that my service is working fine but the
 problem is I am in an area where location is unavalaible and my friend 
 is
 in an area where location is availaible.
 How should* *I fix this that my location also can be transmitted to
 my server!!!

 Now I think ii could be solved
 Please Help!!


 On Fri, Oct 4, 2013 at 9:47 AM, HImanshu Mittal 
 himanshu5...@gmail.com wrote:

 package com.example.metro;

 import com.dude5692.StaticURL.ProjectURL;

 import json.jSOn;

 import android.app.Service;
 import android.content.Context;
 import android.content.Intent;
 import android.content.SharedPreferences;
 import android.location.Criteria;
 import android.location.Location;
 import android.location.LocationListener;
 import android.location.LocationManager;
 import android.os.AsyncTask;
 import android.os.Bundle;
 import android.os.IBinder;
 import android.widget.Toast;

 public class MyService extends Service
 {
 ProjectURL proURL = new ProjectURL();
 String initialURL;
  SharedPreferences pref;

 @Override
 public void onCreate()
  {
 // TODO Auto-generated method stub
 super.onCreate();
  final LocationManager mlocmag =
 (LocationManager)getSystemService(Context.LOCATION_SERVICE);
 final LocationListener mlocList = new MyLocationList();

 Criteria criteria = new Criteria();

 // Getting the name of the best provider
  final String provider = mlocmag.getBestProvider(criteria, true);

 final Location loc = mlocmag.getLastKnownLocation(provider);
  UpdateWithNewLocation(loc); // This method is used to get updated
 location.
 mlocmag.requestLocationUpdates(provider, 1000, 0, mlocList);
  }

 @Override
 public IBinder onBind(Intent arg0)
  {
 // TODO Auto-generated method stub
 return null;
  }

 @Override
 public void onDestroy()
  {
 // TODO Auto-generated method stub
 super.onDestroy();
  }

 @Override
 public int onStartCommand(Intent intent, int flags, int startId)
  {
 // TODO Auto-generated method stub
 return super.onStartCommand(intent, flags, startId);
  }
 private void UpdateWithNewLocation(final Location loc)
 {
  // TODO Auto-generated method stub
 if(loc!= null)
 {
  final double lat =loc.getLatitude(); // Updated lat
 final double Long = loc.getLongitude(); // Updated long

 pref = getSharedPreferences(myMetroFile,Context.MODE_PRIVATE);
  System.out.println(MO   Service Running);
  String UniqueDeviceId = pref.getString(DeviceUniqueID, 0);
 initialURL = proURL.projectURL +
 storeLatLong.php?RegID=+lat+Email=+Long+Device=+UniqueDeviceId+Start=NO;
  new Async().execute();
 }
 else
 {
  }
 }

 class Async extends AsyncTaskString, Void, String
  {

 //ProgressDialog progress;

 protected String doInBackground(String... params)
  {
 try
 {
  new jSOn().execute(initialURL);
 }
 catch (Exception e)
  {
 e.printStackTrace();
 }
  return null;
 }

 protected void onPreExecute()
  {
 super.onPreExecute();
 }

  protected void onPostExecute(String result)
 {
 super.onPostExecute(result);
  }
 }

 public class MyLocationList implements LocationListener
  {

 public void onLocationChanged(Location arg0)
 {
  // TODO Auto-generated method stub
 UpdateWithNewLocation(arg0);
 }

 public void onProviderDisabled(String provider)
 {
 // TODO Auto-generated method stub
  Toast.makeText(getApplicationContext(),GPS Disable ,
 Toast.LENGTH_LONG).show();
 }

  public void onProviderEnabled(String provider)
 {
 // TODO Auto-generated method stub
  Toast.makeText(getApplicationContext(),GPS 

Re: [android-developers] Re: How to make a Service That will periodically send the Users Location on a server

2013-10-04 Thread HImanshu Mittal
Sir Can u tell me .. I am developing an application..
Its is running fine on ICS.. but it is crashing on jElly bean...
??


On Fri, Oct 4, 2013 at 8:48 PM, HImanshu Mittal himanshu5...@gmail.comwrote:

 No problem Sir,
 I will figure it out Soon!!!

 And thanx once again!! :)


 On Fri, Oct 4, 2013 at 8:34 PM, Mukesh Srivastav mukicha...@gmail.comwrote:

 sorry to say, you looks like collecting the code from here and there and
 making your application.  :(

 cant do the spoon feeding

 sorry.


 On Fri, Oct 4, 2013 at 8:08 PM, HImanshu Mittal 
 himanshu5...@gmail.comwrote:

 Sir,
 Actually, I don't know where this code has to be integrated in my code.
 And that's why confused, IF you tell me that ,
 I would test it right away and tell the update!!


 On Fri, Oct 4, 2013 at 7:52 PM, Mukesh Srivastav 
 mukicha...@gmail.comwrote:

 I think, you have missed the code which i had sent you... check that


 On Fri, Oct 4, 2013 at 7:40 PM, HImanshu Mittal himanshu5...@gmail.com
  wrote:

 I have enabled it ...
 If it was not enabled the blue dot would not have appeared
 But as the permissions are there it appears on the map !!!


 On Fri, Oct 4, 2013 at 7:28 PM, Mukesh Srivastav mukicha...@gmail.com
  wrote:

 The problem could be , Himanshu is missing the Location setting to be
 enabled  :)

 Please check the device setting and test your code.


  On Fri, Oct 4, 2013 at 7:06 PM, Kristopher Micinski 
 krismicin...@gmail.com wrote:

 I guess the problem is, if your location is unavailable, how are you
 expecting that that will be fixed?  This doesn't make any sense, if it's
 not available, it's not available,

 Kris



 On Fri, Oct 4, 2013 at 6:16 AM, HImanshu Mittal 
 himanshu5...@gmail.com wrote:

 Hello friends,
 I have just checked it out that my service is working fine but the
 problem is I am in an area where location is unavalaible and my friend 
 is
 in an area where location is availaible.
 How should* *I fix this that my location also can be transmitted
 to my server!!!

 Now I think ii could be solved
 Please Help!!


 On Fri, Oct 4, 2013 at 9:47 AM, HImanshu Mittal 
 himanshu5...@gmail.com wrote:

 package com.example.metro;

 import com.dude5692.StaticURL.ProjectURL;

 import json.jSOn;

 import android.app.Service;
 import android.content.Context;
 import android.content.Intent;
 import android.content.SharedPreferences;
 import android.location.Criteria;
 import android.location.Location;
 import android.location.LocationListener;
 import android.location.LocationManager;
 import android.os.AsyncTask;
 import android.os.Bundle;
 import android.os.IBinder;
 import android.widget.Toast;

 public class MyService extends Service
 {
 ProjectURL proURL = new ProjectURL();
 String initialURL;
  SharedPreferences pref;

 @Override
 public void onCreate()
  {
 // TODO Auto-generated method stub
 super.onCreate();
  final LocationManager mlocmag =
 (LocationManager)getSystemService(Context.LOCATION_SERVICE);
 final LocationListener mlocList = new MyLocationList();

 Criteria criteria = new Criteria();

 // Getting the name of the best provider
  final String provider = mlocmag.getBestProvider(criteria, true);

 final Location loc = mlocmag.getLastKnownLocation(provider);
  UpdateWithNewLocation(loc); // This method is used to get
 updated location.
 mlocmag.requestLocationUpdates(provider, 1000, 0, mlocList);
  }

 @Override
 public IBinder onBind(Intent arg0)
  {
 // TODO Auto-generated method stub
 return null;
  }

 @Override
 public void onDestroy()
  {
 // TODO Auto-generated method stub
 super.onDestroy();
  }

 @Override
 public int onStartCommand(Intent intent, int flags, int startId)
  {
 // TODO Auto-generated method stub
 return super.onStartCommand(intent, flags, startId);
  }
 private void UpdateWithNewLocation(final Location loc)
 {
  // TODO Auto-generated method stub
 if(loc!= null)
 {
  final double lat =loc.getLatitude(); // Updated lat
 final double Long = loc.getLongitude(); // Updated long

 pref = getSharedPreferences(myMetroFile,Context.MODE_PRIVATE);
  System.out.println(MO   Service Running);
  String UniqueDeviceId = pref.getString(DeviceUniqueID, 0);
 initialURL = proURL.projectURL +
 storeLatLong.php?RegID=+lat+Email=+Long+Device=+UniqueDeviceId+Start=NO;
  new Async().execute();
 }
 else
 {
  }
 }

 class Async extends AsyncTaskString, Void, String
  {

 //ProgressDialog progress;

 protected String doInBackground(String... params)
  {
 try
 {
  new jSOn().execute(initialURL);
 }
 catch (Exception e)
  {
 e.printStackTrace();
 }
  return null;
 }

 protected void onPreExecute()
  {
 super.onPreExecute();
 }

  protected void onPostExecute(String result)
 {
 super.onPostExecute(result);
  }
 }

 public class MyLocationList implements LocationListener
  {

 public void onLocationChanged(Location arg0)
 {
  // TODO Auto-generated method stub
 UpdateWithNewLocation(arg0);
 }

 public void onProviderDisabled(String provider)
 {
 // TODO Auto-generated method stub
  

Re: [android-developers] Re: How to make a Service That will periodically send the Users Location on a server

2013-10-04 Thread Kristopher Micinski
Post a stack trace and perhaps someone can help

Kris



On Fri, Oct 4, 2013 at 11:28 AM, HImanshu Mittal himanshu5...@gmail.comwrote:

 Sir Can u tell me .. I am developing an application..
 Its is running fine on ICS.. but it is crashing on jElly bean...
 ??


 On Fri, Oct 4, 2013 at 8:48 PM, HImanshu Mittal himanshu5...@gmail.comwrote:

 No problem Sir,
 I will figure it out Soon!!!

 And thanx once again!! :)


 On Fri, Oct 4, 2013 at 8:34 PM, Mukesh Srivastav mukicha...@gmail.comwrote:

 sorry to say, you looks like collecting the code from here and there and
 making your application.  :(

 cant do the spoon feeding

 sorry.


 On Fri, Oct 4, 2013 at 8:08 PM, HImanshu Mittal 
 himanshu5...@gmail.comwrote:

 Sir,
 Actually, I don't know where this code has to be integrated in my code.
 And that's why confused, IF you tell me that ,
 I would test it right away and tell the update!!


 On Fri, Oct 4, 2013 at 7:52 PM, Mukesh Srivastav 
 mukicha...@gmail.comwrote:

 I think, you have missed the code which i had sent you... check that


 On Fri, Oct 4, 2013 at 7:40 PM, HImanshu Mittal 
 himanshu5...@gmail.com wrote:

 I have enabled it ...
 If it was not enabled the blue dot would not have appeared
 But as the permissions are there it appears on the map !!!


 On Fri, Oct 4, 2013 at 7:28 PM, Mukesh Srivastav 
 mukicha...@gmail.com wrote:

 The problem could be , Himanshu is missing the Location setting to
 be enabled  :)

 Please check the device setting and test your code.


  On Fri, Oct 4, 2013 at 7:06 PM, Kristopher Micinski 
 krismicin...@gmail.com wrote:

 I guess the problem is, if your location is unavailable, how are
 you expecting that that will be fixed?  This doesn't make any sense, if
 it's not available, it's not available,

 Kris



 On Fri, Oct 4, 2013 at 6:16 AM, HImanshu Mittal 
 himanshu5...@gmail.com wrote:

 Hello friends,
 I have just checked it out that my service is working fine but the
 problem is I am in an area where location is unavalaible and my 
 friend is
 in an area where location is availaible.
 How should* *I fix this that my location also can be transmitted
 to my server!!!

 Now I think ii could be solved
 Please Help!!


 On Fri, Oct 4, 2013 at 9:47 AM, HImanshu Mittal 
 himanshu5...@gmail.com wrote:

 package com.example.metro;

 import com.dude5692.StaticURL.ProjectURL;

 import json.jSOn;

 import android.app.Service;
 import android.content.Context;
 import android.content.Intent;
 import android.content.SharedPreferences;
 import android.location.Criteria;
 import android.location.Location;
 import android.location.LocationListener;
 import android.location.LocationManager;
 import android.os.AsyncTask;
 import android.os.Bundle;
 import android.os.IBinder;
 import android.widget.Toast;

 public class MyService extends Service
 {
 ProjectURL proURL = new ProjectURL();
 String initialURL;
  SharedPreferences pref;

 @Override
 public void onCreate()
  {
 // TODO Auto-generated method stub
 super.onCreate();
  final LocationManager mlocmag =
 (LocationManager)getSystemService(Context.LOCATION_SERVICE);
 final LocationListener mlocList = new MyLocationList();

 Criteria criteria = new Criteria();

 // Getting the name of the best provider
  final String provider = mlocmag.getBestProvider(criteria, true);

 final Location loc = mlocmag.getLastKnownLocation(provider);
  UpdateWithNewLocation(loc); // This method is used to get
 updated location.
 mlocmag.requestLocationUpdates(provider, 1000, 0, mlocList);
  }

 @Override
 public IBinder onBind(Intent arg0)
  {
 // TODO Auto-generated method stub
 return null;
  }

 @Override
 public void onDestroy()
  {
 // TODO Auto-generated method stub
 super.onDestroy();
  }

 @Override
 public int onStartCommand(Intent intent, int flags, int startId)
  {
 // TODO Auto-generated method stub
 return super.onStartCommand(intent, flags, startId);
  }
 private void UpdateWithNewLocation(final Location loc)
 {
  // TODO Auto-generated method stub
 if(loc!= null)
 {
  final double lat =loc.getLatitude(); // Updated lat
 final double Long = loc.getLongitude(); // Updated long

 pref = getSharedPreferences(myMetroFile,Context.MODE_PRIVATE);
  System.out.println(MO   Service Running);
  String UniqueDeviceId = pref.getString(DeviceUniqueID, 0);
 initialURL = proURL.projectURL +
 storeLatLong.php?RegID=+lat+Email=+Long+Device=+UniqueDeviceId+Start=NO;
  new Async().execute();
 }
 else
 {
  }
 }

 class Async extends AsyncTaskString, Void, String
  {

 //ProgressDialog progress;

 protected String doInBackground(String... params)
  {
 try
 {
  new jSOn().execute(initialURL);
 }
 catch (Exception e)
  {
 e.printStackTrace();
 }
  return null;
 }

 protected void onPreExecute()
  {
 super.onPreExecute();
 }

  protected void onPostExecute(String result)
 {
 super.onPostExecute(result);
  }
 }

 public class MyLocationList implements LocationListener
  {

 public void onLocationChanged(Location arg0)
 {
  // TODO Auto-generated 

[android-developers] Re: How to make a Service That will periodically send the Users Location on a server

2013-10-03 Thread Piren
this subject has been discussed quite a lot, i suggest you search the net 
and this forum for answers. 

the short list of things you need to know:
- use location change listeners for changes when the device is awake and 
responding
- use alarms to wake the device for periodical updates
- Since a service does not guarantee it will remain alive to send the 
location changes, make sure you take a power/cpu wake lock every time a 
change needs to be sent (especially when being awoken by an alarm)
- do not try to keep a service as foreground and keep the wake lock 
forever, this will just drain the battery. let the device sleep and only 
use wake locks for updating.
- remember that the location returned is the last known one, let the device 
get a fix on it's current location.

On Thursday, October 3, 2013 5:55:23 PM UTC+3, HImanshu Mittal wrote:

 Hello

 I am building the app that requires that users location has to be updated 
 on my server periodically or to be more efficient only when its location 
 has been updated.
 For that a Service will run on its device.
 But I am not able to develop that till now haven't found that does that 
 perfectly.
 Please help


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [android-developers] Re: How to make a Service That will periodically send the Users Location on a server

2013-10-03 Thread HImanshu Mittal
I have been trying that to build it, but I am still not successful in
making that.
I would be really great if you could provide the code if you have made it!!
:)


On Thu, Oct 3, 2013 at 9:03 PM, Piren gpi...@gmail.com wrote:

 this subject has been discussed quite a lot, i suggest you search the net
 and this forum for answers.

 the short list of things you need to know:
 - use location change listeners for changes when the device is awake and
 responding
 - use alarms to wake the device for periodical updates
 - Since a service does not guarantee it will remain alive to send the
 location changes, make sure you take a power/cpu wake lock every time a
 change needs to be sent (especially when being awoken by an alarm)
 - do not try to keep a service as foreground and keep the wake lock
 forever, this will just drain the battery. let the device sleep and only
 use wake locks for updating.
 - remember that the location returned is the last known one, let the
 device get a fix on it's current location.


 On Thursday, October 3, 2013 5:55:23 PM UTC+3, HImanshu Mittal wrote:

 Hello

 I am building the app that requires that users location has to be updated
 on my server periodically or to be more efficient only when its location
 has been updated.
 For that a Service will run on its device.
 But I am not able to develop that till now haven't found that does that
 perfectly.
 Please help

  --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en
 ---
 You received this message because you are subscribed to a topic in the
 Google Groups Android Developers group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/android-developers/cFXbDUmDh6E/unsubscribe
 .
 To unsubscribe from this group and all its topics, send an email to
 android-developers+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [android-developers] Re: How to make a Service That will periodically send the Users Location on a server

2013-10-03 Thread Steve Gabrilowitz
You are more likely to get help developing your own service if tell us in
which areas you have been less than successful.  If you are looking for a
full piece of code already written for you then try Google ;-)
On Oct 3, 2013 11:49 AM, HImanshu Mittal himanshu5...@gmail.com wrote:

 I have been trying that to build it, but I am still not successful in
 making that.
 I would be really great if you could provide the code if you have made it!!
 :)


 On Thu, Oct 3, 2013 at 9:03 PM, Piren gpi...@gmail.com wrote:

 this subject has been discussed quite a lot, i suggest you search the net
 and this forum for answers.

 the short list of things you need to know:
 - use location change listeners for changes when the device is awake and
 responding
 - use alarms to wake the device for periodical updates
 - Since a service does not guarantee it will remain alive to send the
 location changes, make sure you take a power/cpu wake lock every time a
 change needs to be sent (especially when being awoken by an alarm)
 - do not try to keep a service as foreground and keep the wake lock
 forever, this will just drain the battery. let the device sleep and only
 use wake locks for updating.
 - remember that the location returned is the last known one, let the
 device get a fix on it's current location.


 On Thursday, October 3, 2013 5:55:23 PM UTC+3, HImanshu Mittal wrote:

 Hello

 I am building the app that requires that users location has to be
 updated on my server periodically or to be more efficient only when its
 location has been updated.
 For that a Service will run on its device.
 But I am not able to develop that till now haven't found that does that
 perfectly.
 Please help

  --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en
 ---
 You received this message because you are subscribed to a topic in the
 Google Groups Android Developers group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/android-developers/cFXbDUmDh6E/unsubscribe
 .
 To unsubscribe from this group and all its topics, send an email to
 android-developers+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


  --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Android Developers group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to android-developers+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [android-developers] Re: How to make a Service That will periodically send the Users Location on a server

2013-10-03 Thread HImanshu Mittal
Bro , Don't dramatize things out here. I have asked a question thats it.
For the first the first time I have asked a question on any forum regarding
a help in my 8 months of development time.
I was not able to make a code because the code which I have made is not
working.
If you can provide the code than it will be really be helpful or I can also
post my code out here than you can tell me where I am doing it wrong
:)


On Thu, Oct 3, 2013 at 9:23 PM, Steve Gabrilowitz steveg1...@gmail.comwrote:

 You are more likely to get help developing your own service if tell us in
 which areas you have been less than successful.  If you are looking for a
 full piece of code already written for you then try Google ;-)
 On Oct 3, 2013 11:49 AM, HImanshu Mittal himanshu5...@gmail.com wrote:

 I have been trying that to build it, but I am still not successful in
 making that.
 I would be really great if you could provide the code if you have made
 it!!
 :)


 On Thu, Oct 3, 2013 at 9:03 PM, Piren gpi...@gmail.com wrote:

 this subject has been discussed quite a lot, i suggest you search the
 net and this forum for answers.

 the short list of things you need to know:
 - use location change listeners for changes when the device is awake and
 responding
 - use alarms to wake the device for periodical updates
 - Since a service does not guarantee it will remain alive to send the
 location changes, make sure you take a power/cpu wake lock every time a
 change needs to be sent (especially when being awoken by an alarm)
 - do not try to keep a service as foreground and keep the wake lock
 forever, this will just drain the battery. let the device sleep and only
 use wake locks for updating.
 - remember that the location returned is the last known one, let the
 device get a fix on it's current location.


 On Thursday, October 3, 2013 5:55:23 PM UTC+3, HImanshu Mittal wrote:

 Hello

 I am building the app that requires that users location has to be
 updated on my server periodically or to be more efficient only when its
 location has been updated.
 For that a Service will run on its device.
 But I am not able to develop that till now haven't found that does that
 perfectly.
 Please help

  --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en
 ---
 You received this message because you are subscribed to a topic in the
 Google Groups Android Developers group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/android-developers/cFXbDUmDh6E/unsubscribe
 .
 To unsubscribe from this group and all its topics, send an email to
 android-developers+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


  --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en
 ---
 You received this message because you are subscribed to the Google Groups
 Android Developers group.
 To unsubscribe from this group and stop receiving emails from it, send an
 email to android-developers+unsubscr...@googlegroups.com.

 For more options, visit https://groups.google.com/groups/opt_out.

  --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en
 ---
 You received this message because you are subscribed to a topic in the
 Google Groups Android Developers group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/android-developers/cFXbDUmDh6E/unsubscribe
 .
 To unsubscribe from this group and all its topics, send an email to
 android-developers+unsubscr...@googlegroups.com.
 For more options, visit https://groups.google.com/groups/opt_out.


-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop 

Re: [android-developers] Re: How to make a Service That will periodically send the Users Location on a server

2013-10-03 Thread Lew
 HImanshu Mittal wrote:

 Bro , Don't dramatize things out here. I have asked a question thats it.


How is asking for relevant details dramatizing it?

It's spelled that's.
 

 For the first the first time I have asked a question on any forum 
 regarding a help in my 8 months of development time.


Not important.
 

 I was not able to make a code because the code which I have made is not 
 working.


That's like telling a doctor, I don't feel well and expecting a 
diagnosis. You need to provide details.
 

 If you can provide the code than it will be really be helpful or I can 
 also post my code out here than you can tell me where I am doing it wrong

 

 :)


Since that's what the guy was asking for, why do you give him a hard time? 


 On Thu, Oct 3, 2013 at 9:23 PM, Steve Gabrilowitz 
 steve...@gmail.comjavascript:
  wrote:

 You are more likely to get help developing your own service if tell us in 
 which areas you have been less than successful.  If you are looking for a 
 full piece of code already written for you then try Google ;-)

 Follow his advice.

-- 
Lew
 

-- 
You received this message because you are subscribed to the Google
Groups Android Developers group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
Android Developers group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to android-developers+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: [android-developers] Re: How to make a Service That will periodically send the Users Location on a server

2013-10-03 Thread HImanshu Mittal
package com.example.metro;

import com.dude5692.StaticURL.ProjectURL;

import json.jSOn;

import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.location.Criteria;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.IBinder;
import android.widget.Toast;

public class MyService extends Service
{
ProjectURL proURL = new ProjectURL();
String initialURL;
SharedPreferences pref;

@Override
public void onCreate()
{
// TODO Auto-generated method stub
super.onCreate();
final LocationManager mlocmag =
(LocationManager)getSystemService(Context.LOCATION_SERVICE);
final LocationListener mlocList = new MyLocationList();

Criteria criteria = new Criteria();

// Getting the name of the best provider
final String provider = mlocmag.getBestProvider(criteria, true);

final Location loc = mlocmag.getLastKnownLocation(provider);
UpdateWithNewLocation(loc); // This method is used to get updated location.
mlocmag.requestLocationUpdates(provider, 1000, 0, mlocList);
}

@Override
public IBinder onBind(Intent arg0)
{
// TODO Auto-generated method stub
return null;
}

@Override
public void onDestroy()
{
// TODO Auto-generated method stub
super.onDestroy();
}

@Override
public int onStartCommand(Intent intent, int flags, int startId)
{
// TODO Auto-generated method stub
return super.onStartCommand(intent, flags, startId);
}
private void UpdateWithNewLocation(final Location loc)
{
// TODO Auto-generated method stub
if(loc!= null)
{
final double lat =loc.getLatitude(); // Updated lat
final double Long = loc.getLongitude(); // Updated long

pref = getSharedPreferences(myMetroFile,Context.MODE_PRIVATE);
 System.out.println(MO   Service Running);
String UniqueDeviceId = pref.getString(DeviceUniqueID, 0);
initialURL = proURL.projectURL +
storeLatLong.php?RegID=+lat+Email=+Long+Device=+UniqueDeviceId+Start=NO;
new Async().execute();
}
else
{
}
}

class Async extends AsyncTaskString, Void, String
{

//ProgressDialog progress;

protected String doInBackground(String... params)
{
try
{
new jSOn().execute(initialURL);
}
catch (Exception e)
{
e.printStackTrace();
}
return null;
}

protected void onPreExecute()
{
super.onPreExecute();
}

protected void onPostExecute(String result)
{
super.onPostExecute(result);
}
}

public class MyLocationList implements LocationListener
{

public void onLocationChanged(Location arg0)
{
// TODO Auto-generated method stub
UpdateWithNewLocation(arg0);
}

public void onProviderDisabled(String provider)
{
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(),GPS Disable ,
Toast.LENGTH_LONG).show();
}

public void onProviderEnabled(String provider)
{
// TODO Auto-generated method stub
Toast.makeText(getApplicationContext(),GPS enabled,
Toast.LENGTH_LONG).show();
}

public void onStatusChanged(String provider, int status, Bundle extras)
{
// TODO Auto-generated method stub
}
}
}


On Fri, Oct 4, 2013 at 4:44 AM, Lew lewbl...@gmail.com wrote:

  HImanshu Mittal wrote:

 Bro , Don't dramatize things out here. I have asked a question thats it.


 How is asking for relevant details dramatizing it?

 It's spelled that's.


 For the first the first time I have asked a question on any forum
 regarding a help in my 8 months of development time.


 Not important.


 I was not able to make a code because the code which I have made is not
 working.


 That's like telling a doctor, I don't feel well and expecting a
 diagnosis. You need to provide details.


 If you can provide the code than it will be really be helpful or I can
 also post my code out here than you can tell me where I am doing it wrong



 :)


 Since that's what the guy was asking for, why do you give him a hard time?


 On Thu, Oct 3, 2013 at 9:23 PM, Steve Gabrilowitz steve...@gmail.comwrote:

 You are more likely to get help developing your own service if tell us
 in which areas you have been less than successful.  If you are looking for
 a full piece of code already written for you then try Google ;-)

 Follow his advice.

 --
 Lew


 --
 You received this message because you are subscribed to the Google
 Groups Android Developers group.
 To post to this group, send email to android-developers@googlegroups.com
 To unsubscribe from this group, send email to
 android-developers+unsubscr...@googlegroups.com
 For more options, visit this group at
 http://groups.google.com/group/android-developers?hl=en
 ---
 You received this message because you are subscribed to a topic in the
 Google Groups Android Developers group.
 To unsubscribe from this topic, visit
 https://groups.google.com/d/topic/android-developers/cFXbDUmDh6E/unsubscribe
 .
 To unsubscribe from this group and all its topics, send an email to
 android-developers+unsubscr...@googlegroups.com.
 For more options, visit