views:

52

answers:

1

I've got two android apps, one with a public void. How would the other app call this function?

+1  A: 

You can not directly call the functions in another application. There are two ways to to achieve something like this.

The more complicated way would it be to have a service running that both your apps bind to to communicate. This would only be the way to go if you have frequent data sharings etc.

Another method is to use startActivityForResult. This will redirect the user to the activity of the other application and if the activity is finished you will be returned to your old activity and the set result is given to you in onActivityOnResult

Janusz
thanks for reply but not sure if it can work. little bit more info about the app: having a service was my first choice but apparently they can only run in the UI thread. so i decided to split the app into two (kind of a backend and frontend). The activity is already running so not sure if startActivityForResult would work?
ng93
what do you mean can only run in the UI Thread? What is the function doing that you want to call?
Janusz
was told that a service could only run in the ui thread which would mean making the app unresponsive for the 20-30 seconds it needed to do its job. but no worries figured it out now cheers for the help
ng93