Results 1 to 6 of 6

Thread: how to start an android service with proton

  1. #1
    Squire
    Join Date
    Apr 2011
    Posts
    26

    Default how to start an android service with proton

    Hi
    I need to create a service, and it needs to connect to a service of another app. Easy in a regular android app but I have no idea how to do either in Proton. Adding on to the existing java structure seems to blow everything up instantly, and how to connect to an app that doesn't exist in the proton space is also unclear to me.
    Some hints to put me in the right direction would be greatly appreciated.
    Thanks.

  2. #2
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    5,377

    Default

    Hmm, this really has to be done 100% on the Java side, you'll have to change that part.

    Proton shouldn't cause you any problems though.

    Later, if you want to start/stop/initiate/ something on the Java side from Proton (and get a return value) , I can help you do that though.
    Seth A. Robinson
    Robinson Technologies

  3. #3
    Squire
    Join Date
    Apr 2011
    Posts
    26

    Default

    Yeah I was just thoroughly confused on how to do it. I've now managed to let the user start a service by the ontouch java function running code that returns a value from native. I still need to connect it to a button function that originates in native code and sends to java rather than the other way around. I don't know if you have such a function already and I'm not seeing it.. despite my progress I am still quite confused.

    The second problem is that I have another service from an app not developed by me that I need to connect to, it's not a proton app (just your regular eclipse project) and I don't know how to make my proton app see it.

    Thanks.

  4. #4
    Administrator Seth's Avatar
    Join Date
    Jul 2002
    Location
    Japan
    Posts
    5,377

    Default

    [QUOTE]Ok - hrm, one way to initiate something in Java from native is to send a "Native OS message", which the Java side will poll.

    If you search for "MESSAGE_FINISH_APP" you can sort of use that as an example:

    Copy that basic style but add your own message type like this:

    Code:
    #define MESSAGE_MY_OWN_MESSAGE 1000 //start after 1000 to not conflict with my own system messages I might add
    This way it won't conflict with new messages in the engine.

    Schedule it to send from Native like this:

    Code:
    OSMessage o;
    	o.m_type = MESSAGE_MY_OWN_MESSAGE;
    	GetBaseApp()->AddOSMessage(o);
    Now, edit SharedActivity.java's OnDrawFrame and add handling for that message, you'll see where it already handles the others, you'd just add an area to that switch.

    If you need to pass some parms, you can search for MESSAGE_SET_ACCELEROMETER_UPDATE_HZ to see how it does it.

    It WOULD also be possible to call Java functions the "JNI" way, but this method is sort of simpler and less error prone I think.
    Seth A. Robinson
    Robinson Technologies

  5. #5
    Squire
    Join Date
    Apr 2011
    Posts
    26

    Default

    The normal JNI way always seemed needlessly complex to me. I did it your way, it's super easy.
    Thanks!

  6. #6
    Squire
    Join Date
    Apr 2011
    Posts
    26

    Default

    How about the other way around?
    I'm trying to send data from java to proton, which works up until androidutils.cpp. From there I still need to get to the app itself to do anything. My best guess was adding a function in BaseApp but just adding an empty function makes it completely unresponsive. It runs but doesn't react to touch or back button.

Similar Threads

  1. Android build error
    By Le Viet Bach in forum Proton SDK
    Replies: 1
    Last Post: 01-10-2011, 06:49 PM
  2. Proton SVN commit today
    By Seth in forum Proton SDK
    Replies: 0
    Last Post: 11-16-2010, 10:50 AM
  3. Failing Android build
    By rzuf in forum Proton SDK
    Replies: 1
    Last Post: 11-11-2010, 10:57 PM
  4. Proton SDK Forum area opened
    By Seth in forum Proton SDK
    Replies: 0
    Last Post: 10-27-2010, 12:28 PM
  5. Screwed Up! Do I Have to Start Over?
    By in forum Dink Smallwood HD
    Replies: 1
    Last Post: 01-05-2006, 03:09 PM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •