Xamarin Android GCM关闭虚拟机

时间:2015-01-23 18:03:39

标签: java c# android xamarin xamarin.android

在Xamarin Android上使用Google Cloud Messaging时,该应用程序在注册时变得无法响应。这是我的代码:

Thread t = new Thread (new ThreadStart (delegate {
            Console.WriteLine ("Subscribing to Push Notifications");
            try {
                var gcm = GoogleCloudMessaging.GetInstance (this);
                var key = gcm.Register (new string[]{ "12345678" });
                Console.WriteLine ("Reg ID: " + key);
                gcm.Close();
            } catch (Exception ex) {
                Console.WriteLine (ex.ToString ());
            }
        }));

        t.Start ();

如果我运行gcm.Register,它会冻结应用并记录日志:

Shutting down VM

甚至更奇怪的是,我在关闭之前成功获得了注册ID。

任何帮助都将不胜感激。

1 个答案:

答案 0 :(得分:1)

如果这有助于将来的用户,我设法通过删除所有过去的推送通知相关代码来解决此问题,并遵循以下步骤:http://developer.xamarin.com/guides/cross-platform/application_fundamentals/notifications/android/remote_notifications_in_android/

相关问题