IObserver is missing methods
The Observable
class already works, however I am still struggeling with the IObserver
.
In the Xamarin documentation for the 'IObserver' it says, that I only have to implement the Update()
method for the interface IObserver
.
My problems:
when I add the
: IObserver
I get an error that I do not implement these two methods:
public IntPtr Handle => throw new NotImplementedException();
public void Dispose()
{
throw new NotImplementedException();
}
Why do I need these methods and what are they for? They are not mentioned in the Xamarin documentation.
When I add these methods, I get the follwing error message:
error XA4212: TypefirstTry3.bluetoothConnectionActivity/deviceFoundObserver
implementsAndroid.Runtime.IJavaObject
but does not inheritJava.Lang.Object
orJava.Lang.Throwable
. This is not supported.When I add
override
to the update method, the compiler says that there is no suitable method to override
Here is my code:
public class deviceFoundObserver : IObserver
{
bluetoothConnectionActivity mActivity;
public deviceFoundObserver(bluetoothConnectionActivity a)
{
mActivity = a;
}
//function is called from subject observable whenever a change happened
public override void Update(Observable observable, Java.Lang.Object data) //perhaps arguments like this: Observable observable, Object data
{
//there could be other messages as well, so first check wheather it is the right call from observer
if ((string)data == deviceName)
{
mActivity.buttonStartEKG.Visibility = ViewStates.Visible;
Log.Info(constants.tag, MethodBase.GetCurrentMethod().Name + ": Observable called update function in Observer");
}
}
}
I assume that I got something wrong in the way the Observer is used. Can anyone help me out?
c#

add a comment |
The Observable
class already works, however I am still struggeling with the IObserver
.
In the Xamarin documentation for the 'IObserver' it says, that I only have to implement the Update()
method for the interface IObserver
.
My problems:
when I add the
: IObserver
I get an error that I do not implement these two methods:
public IntPtr Handle => throw new NotImplementedException();
public void Dispose()
{
throw new NotImplementedException();
}
Why do I need these methods and what are they for? They are not mentioned in the Xamarin documentation.
When I add these methods, I get the follwing error message:
error XA4212: TypefirstTry3.bluetoothConnectionActivity/deviceFoundObserver
implementsAndroid.Runtime.IJavaObject
but does not inheritJava.Lang.Object
orJava.Lang.Throwable
. This is not supported.When I add
override
to the update method, the compiler says that there is no suitable method to override
Here is my code:
public class deviceFoundObserver : IObserver
{
bluetoothConnectionActivity mActivity;
public deviceFoundObserver(bluetoothConnectionActivity a)
{
mActivity = a;
}
//function is called from subject observable whenever a change happened
public override void Update(Observable observable, Java.Lang.Object data) //perhaps arguments like this: Observable observable, Object data
{
//there could be other messages as well, so first check wheather it is the right call from observer
if ((string)data == deviceName)
{
mActivity.buttonStartEKG.Visibility = ViewStates.Visible;
Log.Info(constants.tag, MethodBase.GetCurrentMethod().Name + ": Observable called update function in Observer");
}
}
}
I assume that I got something wrong in the way the Observer is used. Can anyone help me out?
c#

add a comment |
The Observable
class already works, however I am still struggeling with the IObserver
.
In the Xamarin documentation for the 'IObserver' it says, that I only have to implement the Update()
method for the interface IObserver
.
My problems:
when I add the
: IObserver
I get an error that I do not implement these two methods:
public IntPtr Handle => throw new NotImplementedException();
public void Dispose()
{
throw new NotImplementedException();
}
Why do I need these methods and what are they for? They are not mentioned in the Xamarin documentation.
When I add these methods, I get the follwing error message:
error XA4212: TypefirstTry3.bluetoothConnectionActivity/deviceFoundObserver
implementsAndroid.Runtime.IJavaObject
but does not inheritJava.Lang.Object
orJava.Lang.Throwable
. This is not supported.When I add
override
to the update method, the compiler says that there is no suitable method to override
Here is my code:
public class deviceFoundObserver : IObserver
{
bluetoothConnectionActivity mActivity;
public deviceFoundObserver(bluetoothConnectionActivity a)
{
mActivity = a;
}
//function is called from subject observable whenever a change happened
public override void Update(Observable observable, Java.Lang.Object data) //perhaps arguments like this: Observable observable, Object data
{
//there could be other messages as well, so first check wheather it is the right call from observer
if ((string)data == deviceName)
{
mActivity.buttonStartEKG.Visibility = ViewStates.Visible;
Log.Info(constants.tag, MethodBase.GetCurrentMethod().Name + ": Observable called update function in Observer");
}
}
}
I assume that I got something wrong in the way the Observer is used. Can anyone help me out?
c#

The Observable
class already works, however I am still struggeling with the IObserver
.
In the Xamarin documentation for the 'IObserver' it says, that I only have to implement the Update()
method for the interface IObserver
.
My problems:
when I add the
: IObserver
I get an error that I do not implement these two methods:
public IntPtr Handle => throw new NotImplementedException();
public void Dispose()
{
throw new NotImplementedException();
}
Why do I need these methods and what are they for? They are not mentioned in the Xamarin documentation.
When I add these methods, I get the follwing error message:
error XA4212: TypefirstTry3.bluetoothConnectionActivity/deviceFoundObserver
implementsAndroid.Runtime.IJavaObject
but does not inheritJava.Lang.Object
orJava.Lang.Throwable
. This is not supported.When I add
override
to the update method, the compiler says that there is no suitable method to override
Here is my code:
public class deviceFoundObserver : IObserver
{
bluetoothConnectionActivity mActivity;
public deviceFoundObserver(bluetoothConnectionActivity a)
{
mActivity = a;
}
//function is called from subject observable whenever a change happened
public override void Update(Observable observable, Java.Lang.Object data) //perhaps arguments like this: Observable observable, Object data
{
//there could be other messages as well, so first check wheather it is the right call from observer
if ((string)data == deviceName)
{
mActivity.buttonStartEKG.Visibility = ViewStates.Visible;
Log.Info(constants.tag, MethodBase.GetCurrentMethod().Name + ": Observable called update function in Observer");
}
}
}
I assume that I got something wrong in the way the Observer is used. Can anyone help me out?
c#

c#

asked Jan 2 at 15:19
MarkusNYMarkusNY
105
105
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Why do I need these methods and what are they for? They are not
mentioned in the Xamarin documentation.
Let's have a look at definition of IObserver
:
namespace Java.Util
{
public interface IObserver : IJavaObject, IDisposable
{
void Update(Observable o, Lang.Object arg);
}
}
The two methods is not mentioned here, however we can find out that IObserver
inherits from IJavaObject
and IDisposable
. Then go to the definition of IJavaObject
and IDisposable
:
namespace Android.Runtime
{
public interface IJavaObject : IDisposable
{
IntPtr Handle { get; }
}
}
namespace System
{
public interface IDisposable
{
void Dispose();
}
}
We can find the two methods here. A class or struct that implements the interface must implement the members of the interface that are specified in the interface definition. You should also implement the method defined in the IJavaObject
and IDisposable
.
When I add these methods, I get the follwing error message: error
XA4212:.....
I did not get this error after add these methods. Try again and you can refer these similar questions:error-xa4212, implementing-java-interfaces.
When I add override to the update method, the compiler says that there
is no suitable method to override
You should not add override to the update method. Just implement the method defined in the interface instead of override. You can have a look a interface definition here.
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54008847%2fiobserver-is-missing-methods%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Why do I need these methods and what are they for? They are not
mentioned in the Xamarin documentation.
Let's have a look at definition of IObserver
:
namespace Java.Util
{
public interface IObserver : IJavaObject, IDisposable
{
void Update(Observable o, Lang.Object arg);
}
}
The two methods is not mentioned here, however we can find out that IObserver
inherits from IJavaObject
and IDisposable
. Then go to the definition of IJavaObject
and IDisposable
:
namespace Android.Runtime
{
public interface IJavaObject : IDisposable
{
IntPtr Handle { get; }
}
}
namespace System
{
public interface IDisposable
{
void Dispose();
}
}
We can find the two methods here. A class or struct that implements the interface must implement the members of the interface that are specified in the interface definition. You should also implement the method defined in the IJavaObject
and IDisposable
.
When I add these methods, I get the follwing error message: error
XA4212:.....
I did not get this error after add these methods. Try again and you can refer these similar questions:error-xa4212, implementing-java-interfaces.
When I add override to the update method, the compiler says that there
is no suitable method to override
You should not add override to the update method. Just implement the method defined in the interface instead of override. You can have a look a interface definition here.
add a comment |
Why do I need these methods and what are they for? They are not
mentioned in the Xamarin documentation.
Let's have a look at definition of IObserver
:
namespace Java.Util
{
public interface IObserver : IJavaObject, IDisposable
{
void Update(Observable o, Lang.Object arg);
}
}
The two methods is not mentioned here, however we can find out that IObserver
inherits from IJavaObject
and IDisposable
. Then go to the definition of IJavaObject
and IDisposable
:
namespace Android.Runtime
{
public interface IJavaObject : IDisposable
{
IntPtr Handle { get; }
}
}
namespace System
{
public interface IDisposable
{
void Dispose();
}
}
We can find the two methods here. A class or struct that implements the interface must implement the members of the interface that are specified in the interface definition. You should also implement the method defined in the IJavaObject
and IDisposable
.
When I add these methods, I get the follwing error message: error
XA4212:.....
I did not get this error after add these methods. Try again and you can refer these similar questions:error-xa4212, implementing-java-interfaces.
When I add override to the update method, the compiler says that there
is no suitable method to override
You should not add override to the update method. Just implement the method defined in the interface instead of override. You can have a look a interface definition here.
add a comment |
Why do I need these methods and what are they for? They are not
mentioned in the Xamarin documentation.
Let's have a look at definition of IObserver
:
namespace Java.Util
{
public interface IObserver : IJavaObject, IDisposable
{
void Update(Observable o, Lang.Object arg);
}
}
The two methods is not mentioned here, however we can find out that IObserver
inherits from IJavaObject
and IDisposable
. Then go to the definition of IJavaObject
and IDisposable
:
namespace Android.Runtime
{
public interface IJavaObject : IDisposable
{
IntPtr Handle { get; }
}
}
namespace System
{
public interface IDisposable
{
void Dispose();
}
}
We can find the two methods here. A class or struct that implements the interface must implement the members of the interface that are specified in the interface definition. You should also implement the method defined in the IJavaObject
and IDisposable
.
When I add these methods, I get the follwing error message: error
XA4212:.....
I did not get this error after add these methods. Try again and you can refer these similar questions:error-xa4212, implementing-java-interfaces.
When I add override to the update method, the compiler says that there
is no suitable method to override
You should not add override to the update method. Just implement the method defined in the interface instead of override. You can have a look a interface definition here.
Why do I need these methods and what are they for? They are not
mentioned in the Xamarin documentation.
Let's have a look at definition of IObserver
:
namespace Java.Util
{
public interface IObserver : IJavaObject, IDisposable
{
void Update(Observable o, Lang.Object arg);
}
}
The two methods is not mentioned here, however we can find out that IObserver
inherits from IJavaObject
and IDisposable
. Then go to the definition of IJavaObject
and IDisposable
:
namespace Android.Runtime
{
public interface IJavaObject : IDisposable
{
IntPtr Handle { get; }
}
}
namespace System
{
public interface IDisposable
{
void Dispose();
}
}
We can find the two methods here. A class or struct that implements the interface must implement the members of the interface that are specified in the interface definition. You should also implement the method defined in the IJavaObject
and IDisposable
.
When I add these methods, I get the follwing error message: error
XA4212:.....
I did not get this error after add these methods. Try again and you can refer these similar questions:error-xa4212, implementing-java-interfaces.
When I add override to the update method, the compiler says that there
is no suitable method to override
You should not add override to the update method. Just implement the method defined in the interface instead of override. You can have a look a interface definition here.
answered Jan 3 at 2:53


Jack Hua - MSFTJack Hua - MSFT
1,184129
1,184129
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54008847%2fiobserver-is-missing-methods%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown