Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The best way would be to use location services by CWAC Location Poller service is already made for us to use it just you have to give the time interval to wake up it</p> <p>Do it like dis way n you'll need the jar file which you can get it from <a href="https://www.dropbox.com/sh/pgxk2v9l5vl0h2j/3svyZnuwOK/CWAC-LocationPoller.jar" rel="nofollow">https://www.dropbox.com/sh/pgxk2v9l5vl0h2j/3svyZnuwOK/CWAC-LocationPoller.jar</a></p> <p>From your activity start LocationPoller and set the alarm repeating to the time you want </p> <pre><code>AlarmManager alarmMgr = (AlarmManager) getSystemService(ALARM_SERVICE); Intent i = new Intent(this, LocationPoller.class); Bundle bundle = new Bundle(); LocationPollerParameter parameter = new LocationPollerParameter(bundle); parameter.setIntentToBroadcastOnCompletion(new Intent(this, LocationReceiver.class)); // try GPS and fall back to NETWORK_PROVIDER parameter.setProviders(new String[] { LocationManager.GPS_PROVIDER, LocationManager.NETWORK_PROVIDER }); parameter.setTimeout(120000); i.putExtras(bundle); PendingIntent pi = PendingIntent.getBroadcast(this, 0, i, 0); alarmMgr.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime(), 300000, pi); </code></pre> <p>Make a receiver class Location Receiver from where you'll fetch the lat n lon</p> <pre><code>public class LocationReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { try { Bundle b=intent.getExtras(); LocationPollerResult locationResult = new LocationPollerResult(b); Location loc=locationResult.getLocation(); String msg; if (loc==null) { loc=locationResult.getLastKnownLocation(); if (loc==null) { msg=locationResult.getError(); } else { msg="TIMEOUT, lastKnown="+loc.toString(); } } else { msg=loc.toString(); Log.i("Location Latitude", String.valueOf(loc.getLatitude())); Log.i("Location Longitude", String.valueOf(loc.getLongitude())); Log.i("Location Accuracy", String.valueOf(loc.getAccuracy())); } Log.i(getClass().getSimpleName(), "received location: " + msg); } catch (Exception e) { Log.e(getClass().getName(), e.getMessage()); } } </code></pre> <p>and add this to your manifest</p> <pre><code> &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /&gt; &lt;uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /&gt; &lt;uses-permission android:name="android.permission.WAKE_LOCK" /&gt; &lt;receiver android:name="com.commonsware.cwac.locpoll.LocationPoller" /&gt; &lt;service android:name="com.commonsware.cwac.locpoll.LocationPollerService" /&gt; </code></pre> <p>and the receiver declaration where you'll fetch everything</p> <pre><code> &lt;receiver android:name="com.RareMediaCompany.Helios.LocationReceiver" /&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload