Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 755989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T15:11:38+00:00 2026-05-14T15:11:38+00:00

I defined a local Service: public class ComService extends Service implements IComService { private

  • 0

I defined a local Service:

public class ComService extends Service implements IComService {
    private IBinder binder = new ComServiceBinder();

    public class ComServiceBinder extends Binder implements IComService.IServiceBinder {
        public IComService getService() {
            return ComService.this;
        }
    }

    public void test(String msg) {
        System.out.println(msg);
    }

    @Override
    public IBinder onBind(Intent intent) {
        return binder;
    }    
}

The corresponding interface:

public interface IComService {
    public void test(String msg);

    public interface IServiceBinder {
        IComService getService();
    }
}

Then i try to bind the service in another activity in another application, where the same interface is available:

bindService(new Intent("ch.ifi.csg.games4blue.gamebase.api.ComService"), conn, Context.BIND_AUTO_CREATE);

and

private ServiceConnection conn = new ServiceConnection() {
    @Override
    public void onServiceConnected(ComponentName name, IBinder service) {
        Log.i("INFO", "Service bound " + name);
        comService = ((IComService.IServiceBinder)service).getService();
        serviceHandler.sendEmptyMessage(0);
    }

    @Override
    public void onServiceDisconnected(ComponentName arg0) {
        Log.i("INFO", "Service Unbound ");
    }
};

but the line

comService = ((IComService.IServiceBinder)service).getService();

always throws a

05-02 22:12:55.922: ERROR/AndroidRuntime(622): java.lang.ClassCastException: android.os.BinderProxy

I can’t explain why, I followed the app sample on http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/app/LocalServiceBinding.html

Any hints would be nice!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T15:11:38+00:00Added an answer on May 14, 2026 at 3:11 pm

    You need to use AIDL to define interfaces that span applications (so-called “remote services”). You followed a local binding example, but you are not using local binding. Try this and this sample project for a remote binding example using AIDL.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So far I've a class for a simple local service. What I want to
I have a non-service class which is defined as such: class A{ B b
I have defined a local mirror for all repositories in the settings.xml file: <mirror>
I want to use a bunch of local variables defined in a function, outside
If I have have some overloaded ostream operators, defined for library local objects, is
I have defined following control template for my custom control. <ControlTemplate TargetType={x:Type local:CustomControl}> <Grid
I want to define a class method that has access to a local variable.
I defined: a mongoose schema (Type1) to save an object 2 others that extends
I have a WCF Service exposing a single contract and operation: <ServiceContract(Namespace:=ImageSystem)> _ Public
This is my scenario: I have a remote service (local to the Android device

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.