dongpangfu6322 2016-08-29 16:44
浏览 93
已采纳

如果在数据库中插入数据,如何在android中接收通知[关闭]

I have a mySQL database, and I created a simple android app that can display the data from the database using json. And I want to add the function wherein if a data is inserted in my database, the android app will be notified.

For example.I have two android app(App "A" and "B"). App "A" can Insert Data, and "B" can Display the data. I'm thinking of, everytime that App "A" Inserts a data, App "B" will be notified, and can refresh the current displayed data. I am thinking of refresh the list every certain time(5-10sec), but it seems to add more process time, and I think maybe refreshing it only when a data is inserted in the database would be better. Is there a way to do this? Hope that you can provide me some knowledge on how to do this. And if possible some example codes. Thank you.

  • 写回答

1条回答 默认 最新

  • duansaoguan7955 2016-08-29 16:58
    关注

    So if your backend is built using php, this is possible. I assumed that because you've set PHP as a tag.

    Every time someone request to insert data to your php, you can insert it into MySQL and if insert went OK you could Google Cloud Messaging (GCM): https://developers.google.com/cloud-messaging/

    Read documentation well, because GCM is not one-liner. It requires setup on Google console, your PHP server and Android app.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3