简体   繁体   English

如何在网页和Android应用之间传输数据

[英]How To Transmit Data Between A Webpage And An Android-App

I need an approach: My aim is to transmit about every minute a number from an Android-App to Webpage, opened on a Computer. 我需要一种方法:我的目标是每分钟将一个数字从Android应用程序传输到在计算机上打开的网页。 It needs to be fast, the computer just has Firefox installed (I can't install programs) and the devices aren't in the same network (has to be over Internet, not bluetooth or similar). 它需要很快,计算机只安装了Firefox(我无法安装程序),并且设备不在同一网络中(必须通过Internet,而不是蓝牙或类似设备)。

My current solution is a MySQL-Bridge: The opened Webpage on the computer retrieves data from the SQL-Database, filled by the android device, about every second (dirty solution), the problem is, that I use PHP and a while(true)-loop. 我当前的解决方案是MySQL桥:计算机上打开的网页大约每秒从android设备填充的SQL数据库中检索数据(肮脏的解决方案),问题是我使用了PHP一段时间(真)-环。 The webhoster does not allow to set the time limit and I get after a few seconds an error. Webhoster不允许设置时间限制,几秒钟后我得到一个错误。 I have also tried a socket, but then the page loaded the whole time. 我也尝试过使用套接字,但是随后页面始终被加载。 Have I made a mistake there? 我在那里弄错了吗?

What approach is the best one for my project? 什么方法最适合我的项目?

Thanks 谢谢

If you are right about the execution timeout of your php scripts then are there no options you could do. 如果您对php脚本的执行超时是正确的,那么没有选择可以做。 If not, you could try to run the command set_time_limit(0); 如果没有,您可以尝试运行命令set_time_limit(0); , this removes the limit of the script execution. ,这消除了脚本执行的限制。 If this works you could try so use a XMPP like protocol. 如果可行,您可以尝试使用类似XMPP的协议。 I'm sure there are some ready to use libraries. 我确定有一些现成的库可供使用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM