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 <[email protected]>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 AsyncTask<String, 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 <[email protected]> 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 <[email protected]>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 [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> 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
>> [email protected].
>> 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 [email protected]
To unsubscribe from this group, send email to
[email protected]
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 [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to