[mono-android] Generic Binder object from external jar

2013-09-12 Thread Breyer, Christian
Hello,

could someone please tell me how to solve the following issue, if that's 
possible at all?

I'm including an external JAR that exports a Service and a generic Binder class 
called LocalBinder. The sample code on how to work with the JAR looks like 
this:

public void onServiceConnected(ComponentName className, IBinder 
service) {
Log.d(LOG_TAG, "Service connected...");
mService = ((LocalBinder) service).getService();
// ...
}

The IBinder reference is of a different type (Android.OS.Binder) than in this 
Java sample. The C# LocalBinder class is not a generic one and I have no idea 
how to get to the Service-Reference of the Binder since I cannot just cast it.

I embedded the JAR into a "Java Bindings Library" project and included this one 
into mine. I can obviously start the service and the onServiceConnected methods 
is called.

Kind regards
Christian

___
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid


Re: [mono-android] Generic Binder object from external jar

2013-09-12 Thread venkatesh
Hi,

Please refer below link . it may be useful for your issue.

http://mono-for-android.1047100.n5.nabble.com/Bound-Services-td4872509.html
  

Thanks



--
View this message in context: 
http://mono-for-android.1047100.n5.nabble.com/Generic-Binder-object-from-external-jar-tp5713513p5713514.html
Sent from the Mono for Android mailing list archive at Nabble.com.
___
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid


Re: [mono-android] Generic Binder object from external jar

2013-09-12 Thread Breyer, Christian
Thank you for your answer. I'm afraid the issue described in the link you 
posted is of a different kind.


-Ursprüngliche Nachricht-
Von: monodroid-boun...@lists.ximian.com 
[mailto:monodroid-boun...@lists.ximian.com] Im Auftrag von venkatesh
Gesendet: Donnerstag, 12. September 2013 12:32
An: monodroid@lists.ximian.com
Betreff: Re: [mono-android] Generic Binder object from external jar

Hi,

Please refer below link . it may be useful for your issue.

http://mono-for-android.1047100.n5.nabble.com/Bound-Services-td4872509.html
  

Thanks



--
View this message in context: 
http://mono-for-android.1047100.n5.nabble.com/Generic-Binder-object-from-external-jar-tp5713513p5713514.html
Sent from the Mono for Android mailing list archive at Nabble.com.
___
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid



___
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid


Re: [mono-android] Generic Binder object from external jar

2013-09-12 Thread Jonathan Pryor
On Sep 12, 2013, at 5:59 AM, "Breyer, Christian"  wrote:
> I’m including an external JAR that exports a Service and a generic Binder 
> class called LocalBinder. The sample code on how to work with the JAR 
> looks like this:
>  
> public void onServiceConnected(ComponentName className, IBinder 
> service) {
> Log.d(LOG_TAG, "Service connected...");
> mService = ((LocalBinder) service).getService();
> // …
> }
>  
> The IBinder reference is of a different type (Android.OS.Binder) than in this 
> Java sample.

I don't understand what this means.

> The C# LocalBinder class is not a generic one and I have no idea how to get 
> to the Service-Reference of the Binder since I cannot just cast it.

LocalBinder isn't generic because Java generics don't exist. Java uses type 
erasure, and when using Java through JNI -- as is done in Xamarin.Android -- 
the generics have been "erased".

You should be able to cast the service value to the LocalBinder type by using 
the JavaCast() extension method:


http://androidapi.xamarin.com/?link=M%3aAndroid.Runtime.Extensions.JavaCast%3CTResult%3E

For example:

mService = service.JavaCast().Service;

 - Jon

___
Monodroid mailing list
Monodroid@lists.ximian.com

UNSUBSCRIBE INFORMATION:
http://lists.ximian.com/mailman/listinfo/monodroid