2

I'm a new Android programmer and I've been trying to develop an app that utilizes Google Voice Search's voice to text capabilities, calling it using an implicit intent. That's the part that works. However, I'm looking to only have GVS run for a set amount of time, so I've been looking for a way to kill the application.

I have tried: Finish() from several places in the program. If I could get some way to call GVS' finish() command, this would be ideal.

android.os.Process.killProcess(android.os.Process.myPid()) works, but it kills the entire app, which I don't want.

I am looking for: A way to kill the Google Voice Search app used in my program without killing the entire application. The only solution I have right now is to make an Activity that starts GVS and then kill that when I need GVS stopped, but that seems pointlessly messy. Anyone have a better solution?

Edit: I am not having trouble with the service itself. My intent and GVS are working perfectly. What I'm trying to do is interrupt the service so that, if I'm continually toggling the service back on whenever it turns off, I'll be able to stop the program after an amount of time. If I could terminate the process midway through, I'd be quite happy.

Edit2: I may have found a workaround for my issue in simply not refreshing the service when a timer is up.

halfer
  • 19,824
  • 17
  • 99
  • 186
  • Are you receiving the result of the intent? How are you calling the intent? Once you receive the result of the intent the service should close.. If found this… https://software.intel.com/en-us/articles/developing-android-applications-with-voice-recognition-features… perhaps useful for you? – Social_Engineerer Jun 05 '14 at 18:42
  • I saw that article, that's part of how I built my app. I have the intent working perfectly fine. The thing I'm trying to do is interrupt the original service. Kill it midway through. I'll try to clarify that in the main question. – user3712392 Jun 05 '14 at 18:54
  • I realize that. But with outside services usually you would create an intent for result. The service would do it thing, return a value perhaps, then will close. Then are are you talking mid use of the service? – Social_Engineerer Jun 05 '14 at 18:56
  • I am indeed. Sorry if the midway through post of my above message was a little misleading, not used to enter posting the comment instead of going down a line. – user3712392 Jun 05 '14 at 18:58
  • I haven't used this specific service. But In most outside services; google in particular you can usually tap outside of the service window and return to the activity/fragment. If that doesn't work, they not sure. You might then have to put it in a frag and place a button in the action bar to kill the process. But if the service is an outside api and you don't have access to the code, then you will have to read more about the service (read the api) and see if there is a method for what you are trying to do. Sorry I can't be more help! – Social_Engineerer Jun 05 '14 at 19:06
  • Thank you for trying, and I'm able to cancel the service using the "cancel" button of the application, so if I were able to find a way to call that button automatically, I'd be set. You were quite helpful in getting me to clarify my original question though and covered many of the bases that I would have in asking someone, so don't worry about not immediately solving all my issues. The quick responses and good advice were still extremely useful. – user3712392 Jun 05 '14 at 19:12

0 Answers0