当我使用“adb shell am Broadcast”时得到响应

发布于 2024-12-05 01:53:45 字数 361 浏览 1 评论 0原文

我有一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

千鲤 2024-12-12 01:53:45

您的应用程序可以向某个地址发出一些请求,并且在请求的参数中,它可以发送状态,

例如

void somemethod(){
//do stuff
//sendfrlagforfinish on you host adress
//or in case of error send flag for error
}

在您的主机上,您需要运行一个监听器(服务)来接收这些请求,

我已经做了类似的事情,我的请求是我的服务器看起来像这样

www.myserverhostip.com?flag=success

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文