1

Is it possible to bind java services in pure native code? Essentially, calling this part of code in under native C code

Intent i = new Intent(); i.setClassName("com.example.fooservice", "com.example.fooservice.service"); bindService(i, clientConnection, Context.BIND_AUTO_CREATE); 

1 Answer 1

1

No, not directly. However, you could accomplish it calling up to your NativeActivity via JNI.

Sign up to request clarification or add additional context in comments.

3 Comments

I think the tricky part for that is to get the clientConnection's callbacks, is that doable via JNI as well?
Also, why android won't allow native code to access java android service.. that seems a very reasonable thing to do if you are writing a native app..
Android's dev model is to use the runtime, which provides a standardized way for apps to be entered and controlled. Even "native" apps are wrapped in a runtime (the NativeActivity is a thin form of Activity which knows to call your native code based on your meta data.) The framework provided APIs written in Java are more extensive and robust than native code. The ServiceConnection callback is tricky and you wouldn't be able to directly do it in native code. You'd have to extend NativeActivity and write your own to "hook" to get down via JNI to your native code.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.