I'm porting the Google Play IAP example
(http://developer.android.com/guide/google/play/billing/billing_integrate.html#billing-service),
but running into an issue after service is connected. 

In "OnServiceConnected", when I try to cast the "IBinder service" type to
the interface I want to use it as, it always returns null.


Here is their java sample code (in their BillingService, which extends
Service and implements ServiceConnection):

    private static IMarketBillingService mService;
  

    private void bindMarketBillingService() 
    {
        boolean bindResult = bindService(new
Intent("com.android.vending.billing.MarketBillingService.BIND"),   
              this, Context.BIND_AUTO_CREATE);
    }

    /**
    * The Android system calls this when we are connected to the
MarketBillingService.
    */
    public void onServiceConnected(ComponentName name, IBinder service) 
    {   
       mService = IMarketBillingService.Stub.asInterface(service);
    }



Here is my C# (where my BillingService inherits from Service and implements
IServiceConnection):


    private static IMarketBillingService mService;

    private void bindMarketBillingService()
    {
         var result = BindService(new
Intent("com.android.vending.billing.MarketBillingService.BIND"), this, 
                Bind.AutoCreate);
    }

    public void OnServiceConnected(ComponentName name, IBinder service)
    {
         mService = service as IMarketBillingService;
    }


Everything is pretty much verbatim of what they have in their sample. When I
inspect the IBinder service reference when OnServiceConnected is called, the
ItemDescriptor property is the namespace of my IMarketBillingService
interface, though the base type is Java.Lang.Object. The cast will always
result in null.


I did find a post from late last year regarding binding services at: 
     
    
http://mono-for-android.1047100.n5.nabble.com/Bound-Services-td4872509.html

I did get that sample working, but I wasn't able to see how I could extract
a usable IMarketBillingService implementation in doing that. I tried having
the LocalBinder object implement the IMarketBillingService, though I believe
I would still be stuck in actually implementing that method.

Any thoughts? I've been stuck on this for quite a few hours already, so any
assistance would be greatly appreciated. If any more information is needed,
let me know.

thanks,
Dan










--
View this message in context: 
http://mono-for-android.1047100.n5.nabble.com/Binding-Services-casting-interface-on-service-connection-fails-tp5711549.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

Reply via email to