【发布时间】:2017-02-04 05:54:04
【问题描述】:
我已经构建了一个仅供内部使用的简单 Android 应用程序。这个应用程序每隔几秒发送一次数据(GPS 坐标),通过一个简单的 PHP 脚本保存到 mysql。如果json有一定的响应,我确实需要用户的Android设备显示一个预设的通知(如果手机处于待机状态,查看另一个应用程序等时会显示)。
我看过的大多数教程都建议使用 GCM 完成。我原以为,“自推送”通知应该比这更容易。
例如 如果 json 回复“通知:1”,那么 androids 通知将声明“有工作等待”。
有没有简单的方法来做到这一点?如果是这样,请指导我一个简单的解决方案。
new HttpRequestTask(
new HttpRequest("https://www.autoflora.net/driver/gps.php?Driver_ID=" + driver_id + "&latlong=" +
location.getLatitude() + "*" + location.getLongitude(), HttpRequest.POST, "{ \"some\": \"data\" }"),
new HttpRequest.Handler() {
@Override
public void response(HttpResponse response) {
if (response.code == 200) {
Log.d(this.getClass().toString(), "Request successful!");
} else {
Log.e(this.getClass().toString(), "Request unsuccessful: " + response);
}
}
}).execute();
【问题讨论】:
标签: php json android-studio push-notification notifications