1

To get network based location we use below code in java

// Check network provider is available
if( locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER) ) 
{                    
location = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
}

1) So same thing how can i do from Native C code?

2) Is there any native service is available for location in android?

Jeegar Patel
  • 26,264
  • 51
  • 149
  • 222
  • I would suggest that you use fusedlocation. It works brilliantly. Here is the docs: https://developer.android.com/reference/com/google/android/gms/location/FusedLocationProviderApi.html and this is a pretty good example: http://www.kpbird.com/2013/06/fused-location-provider-example.html . – Lunchbox Jan 21 '15 at 14:06
  • @Lunchbox all that stuff are in java i want in C or c++. – Jeegar Patel Jan 22 '15 at 04:54
  • So I geuss you arent using Android Studio? Sorry for the asumption. – Lunchbox Jan 22 '15 at 06:09

2 Answers2

1

You should use NDK. You can develop the main functionality in java using the services provided by Android, and then callback your C code with the results.

X.Otano
  • 2,079
  • 1
  • 22
  • 40
1

No, the NDK only supports a limited number of libraries. It is designed to be used for things that are really processor intensive, and thus would actually benefit from being written in a native language. From the docs, only supported areas:

    libc (C library) headers
    libm (math library) headers
    JNI interface headers
    libz (Zlib compression) headers
    liblog (Android logging) header
    OpenGL ES 1.1 and OpenGL ES 2.0 (3D graphics libraries) headers
    libjnigraphics (Pixel buffer access) header (for Android 2.2 and above)
    Minimal set of headers for C++ support
X.Otano
  • 2,079
  • 1
  • 22
  • 40
  • 1
    yes i agree with that. But android has support of some native services also. Like sensor service is available for native. You can read any sensor value in native – Jeegar Patel Jan 22 '15 at 07:53