Skip to main content

Posts

Showing posts from 2016

How to add host ip address on Android Virtual Device (AVD) or Genymotion using Android Studio

Select  terminal Enter this script AVD adb shell echo '10.0.2.2 hostname' /system/etc/hosts Genymotion adb shell echo '10.0.3.2 hostname' /system/etc/hosts Enter this script to check if the host successfully added adb shell cat /system/etc/hosts Then terminal will print the hosts file list  Enter http://hostname from emulator browser to check if the host can be accessed

Locationlistener on Background Services

Before creating this service if you have requesting location update on the other part of your app, make sure you call removeLocationUpdate(). So the service can get the right location update. LocationServices.FusedLocationApi.removeLocationUpdates(googleApiClient, context); public class LocationTrackingService extends Service implements LocationListener, GoogleApiClient.ConnectionCallbacks, GoogleApiClient.OnConnectionFailedListener{ protected GoogleApiClient googleApiClient; @Override public void onCreate() { } @Override public int onStartCommand(Intent intent, int flags, int startId) { if(googleApiClient != null && !googleApiClient.isConnected()) googleApiClient.connect(); else if(googleApiClient == null) { createGoogleApiClient(); } return START_STICKY; } @Override public IBinder onBind(Intent intent) { return null; } @Override public void onDest