当我使用“adb shell am Broadcast”时得到响应
我有一个 Android 应用程序,它的接收器监听 2 个意图,1 个生成一个线程来写入文件,1 个生成一个线程将同一文件上传到服务器。
我的主机上有一个脚本,需要通过“adb shell am Broadcast”手动将意图发送到接收器。我想发送一个写入文件的意图,然后发送另一个上传文件的意图。但是,创建和上传文件可能需要未知的时间,我需要等待文件完成写入后再上传。
有没有办法让我的 Android 应用程序以某种方式向我的主机脚本发出写入已完成的信号?或者有没有一种方法可以使用我的脚本轮询应用程序,并且应用程序返回文件的状态?
我唯一能想到的是在实际文件完成时创建一个临时文件。该脚本会轮询此临时文件是否存在,并将其用作实际文件已准备好上传的指示符。
I have an Android app with a receiver that listens 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的应用程序可以向某个地址发出一些请求,并且在请求的参数中,它可以发送状态,
例如
在您的主机上,您需要运行一个监听器(服务)来接收这些请求,
我已经做了类似的事情,我的请求是我的服务器看起来像这样
Your app can make some request to some address and in the parameters of the request it can send the status
for example
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