Get a response when I use "adb shell am broadcast"
I have an Android app with a receiver that li开发者_Go百科stens for 2 intents, 1 that spawns a thread to write to a file and 1 that spawns a thread to upload the same file to a server.
I have a script on my host machine that needs to manually send intents to the receiver via "adb shell am broadcast". I want to send an intent to write to a file and then send another intent to upload it. However, both creating and uploading the file can take an unknown amount of time and I need to wait for the file to finish being written before uploading it.
Is there a way for my Android app to somehow signal to my host script that writing is done? Or is there a way I can poll the app with my script and the app returns the status of the file?
The only thing I can think of is creating a temp file when the real file is complete. The script polls for the existence of this temp file and uses it as an indicator that the real file is ready to upload.
Your app can make some request to some address and in the parameters of the request it can send the status
for example
void somemethod(){
//do stuff
//sendfrlagforfinish on you host adress
//or in case of error send flag for error
}
on your host you need to have a listener (service) running that will receive these requests
I have done something similar and my request to my server looked like this
www.myserverhostip.com?flag=success
精彩评论