예제 #1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            textRegistrationStatus = FindViewById <TextView>(Resource.Id.textRegistrationStatus);
            textRegistrationId     = FindViewById <TextView>(Resource.Id.textRegistrationId);
            textLastMsg            = FindViewById <TextView>(Resource.Id.textLastMessage);
            buttonRegister         = FindViewById <Button>(Resource.Id.buttonRegister);

            Log.Info("C2DM-Sharp-UI", "Hello World");

            this.buttonRegister.Click += delegate
            {
                if (!registered)
                {
                    Log.Info("C2DM-Sharp", "Registering...");
                    PushClient.Register(this, senderIdEmail);
                }
                else
                {
                    Log.Info("C2DM-Sharp", "Unregistering...");
                    PushClient.UnRegister(this);
                }

                RunOnUiThread(() =>
                {
                    //Disable the button so that we can't click it again
                    //until we get back to the activity from a notification
                    this.buttonRegister.Enabled = false;
                });
            };
        }
예제 #2
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            textRegistrationStatus = FindViewById <TextView>(Resource.Id.textRegistrationStatus);
            textRegistrationId     = FindViewById <TextView>(Resource.Id.textRegistrationId);
            textLastMsg            = FindViewById <TextView>(Resource.Id.textLastMessage);
            buttonRegister         = FindViewById <Button>(Resource.Id.buttonRegister);

            Log.Info(TAG, "Hello World");

            //Check to ensure everything's setup right
            PushClient.CheckDevice(this);
            PushClient.CheckManifest(this);


            this.buttonRegister.Click += delegate
            {
                if (!registered)
                {
                    Log.Info(TAG, "Registering...");

                    //Call to register
                    PushClient.Register(this, PushHandlerBroadcastReceiver.SENDER_IDS);
                }
                else
                {
                    Log.Info(TAG, "Unregistering...");

                    //Call to unregister
                    PushClient.UnRegister(this);
                }

                RunOnUiThread(() =>
                {
                    //Disable the button so that we can't click it again
                    //until we get back to the activity from a notification
                    this.buttonRegister.Enabled = false;
                });
            };
        }