Bakus123
Bakus123

Reputation: 1399

Java service vs native service

I want to write a service to send location data from gps on the server. The data will be send with frequency 15-60 seconds. I wonder if write it as ordinary service in JAVA if as native service in C. Will it be much better option for battery life when I will write it in C?

If native service in C is much better option, how do I start? Can you give me any example?

Upvotes: 0

Views: 1229

Answers (1)

Alex Cohn
Alex Cohn

Reputation: 57163

No, the guidelines explicitly warn from the superstition that NDK gives performance boost. Even more so, speaking about battery life. Use of native code is justified, first of all, when you can easily reuse significant amount of cross-platform code in C or C++. Usually, this native code is wrapped in Java to provide correct communication with the Android OS.

You can also write a traditional Linux service in C, which will have no interaction with Java layer of the OS. But this will not necesserily be more efficient performance-wise, and will be much harder to make efficient battery-wise, because the relevant API is more easily accessible from Java.

Upvotes: 1

Related Questions