2

我创建了 android 应用程序来发送推送通知。我在 Java 代码中获取设备注册 ID,从如何将注册 ID 发送到 asp.net webapi。下面是webapi方法。

    [System.Web.Http.HttpGet]
    public void SendPushNotification(string deviceRegID, string notificationMessage)
    {
        AndroidGCMPushNotification apnGCM = new AndroidGCMPushNotification();            
        string strResponse = apnGCM.NotifyTest(deviceTokenID, notificationMessage);
    }

我在浏览器中将此 webapi 称为http://www.example.com:80/sendPushNotification/deviceRegID/notificationMessage(example.com:80 是 ipaddress 和端口),它正在被触发。如何从 Android mainactivity 调用它。

4

1 回答 1

0

您可以从 Android 创建并执行正常的 HTTP 请求。你可以看看这个问题的详细信息:Make an HTTP request with android

当然,如果您在本地计算机上托管 WebAPI 应用程序,则必须确保可以从运行 Android 应用程序的模拟器/设备访问该 URL。

于 2013-08-29T11:51:28.500 回答