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

  • Home
  • SEARCH
  • 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 6097233
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:01:12+00:00 2026-05-23T13:01:12+00:00

I have a little Android project going on which involves some IPC where client

  • 0

I have a little Android project going on which involves some IPC where client Activities bind to my service.
I’m using AIDL for IPC and RPC which works pretty good, but I’m having trouble returning a service-side instantiated AIDL interface implementation to the clients:

When the client is running in the same process as the service — meaning running the service locally — everything works just fine.
But when client and service are seperated in different processes the method startLogSession, which is defined in ILogDroidBinder.aidl always returns null.
The other method implemented in this interface — getSessionIds — which returns a List containing ints, always works (locally and cross-process).

I’m taking a wild guess and suppose my ILogDroidSession implementation should also implement Parcelable, but that wouldn’t work, because I can’t parcel an object containg a reference to an SQLiteDatabase (or can I?).

Here is the relevant code.
I’d really be glad if someone could help me out here. Maybe I’m just missing a point somewhere, since this is my first Android project and I’m not quite involved yet.

ILogDroidSession.aidl (An implementation of this is what I want to return to the client):

package net.sourceforge.projects.logdroid;

interface ILogDroidSession {

  /**
   * Logs the given text to the error message channel of the current logging
   * session.
   * @param text Text to log.
   */
  void logError(in String text);
}

ILogDroidBinder.aidl (The IBinder interface passed to the client’s onServiceConnected):

package net.sourceforge.projects.logdroid;

import net.sourceforge.projects.logdroid.ILogDroidSession;
interface ILogDroidBinder {

  /**
   * Starts a new LogDroid session which handles all logging events.
   * @param sessionName The name of the session.
   * @return An instance of ILogDroidSession.
   */
  ILogDroidSession startLogSession(in String sessionName);

  /**
   * Gets a list with all available LogSession ids.
   */
  List getSessionIds();
}

LogDroidService.java (Relevant code from my service):

public class LogDroidService extends Service {

  /**
   * The binder interface needed for Activities to bind to the
   * {@code LogDroidService}.
   */
  private final ILogDroidBinder.Stub binder = new ILogDroidBinder.Stub() {
    /**
     * Starts a new LogDroidSession.
     */
    public ILogDroidSession startLogSession(String sessionName) {
      return LogDroidService.this.createSession(sessionName);
    }

    /**
     * Gets all available session ids.
     */
     public List<Integer> getSessionIds() {
       return LogDroidService.this.getSessionIds();
    }
  };

  /**
   * The database connection to be used for storing and retrieving log entries.
   */
  private LogDroidDb database;

  @Override
  public void onCreate() {
    super.onCreate();
    database = new LogDroidDb(getApplicationContext());
    try {
      database.open(); // opens as writable database
    } catch ( SQLException ignorefornow ) {
    }
  }

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

  /**
   * Creates a new LogDroidSession which will be returned to the user as a
   * AIDL remote object.
   * @param sessionName Name of the session.
   * @return A new instance of ILogDroidSession
   */
  ILogDroidSession createSession(String sessionName) {
    LogDroidSession session = new LogDroidSession(database, sessionName);
    session.addLoggingOccurredListener(this);
    return session;
  }

  /**
   * Retrieves all session ids.
   * @return Array containing all LogDroidSession ids.
   */
  ArrayList<Integer> getSessionIds() {
    return database.getSessionIds();
  }
}

MainActivity.java (Relevant client code):

public class MainActivity extends Activity {

  private ILogDroidSession session;
  private ILogDroidBinder binder;
  private ServiceConnection con = new ServiceConnection() {
    public void onServiceConnected(ComponentName arg0, IBinder arg1) {
      binder = ILogDroidBinder.Stub.asInterface(arg1); // always works
      try {
        // works locally but always returns null when cross-process
        session = binder.startLogSession("TestSession");

        // always works
        List<Integer> ids = binder.getSessionIds();
      } catch ( Exception ex) {
        // no exceptions are thrown either when running locally or cross-process
        Toast.makeText(getApplicationContext(), ex.getMessage(),
          Toast.LENGTH_LONG).show();
      }
    }

    public void onServiceDisconnected(ComponentName arg0) {
    }
  };
}
  • 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-23T13:01:12+00:00Added an answer on May 23, 2026 at 1:01 pm

    ILogDroidSession can be defined as just interface in java file, it shouldn’t be in AIDL.

    If the client and LogDroidService are running in different processes, LogDroidSession should be parcelable to send/receive over IPC.

    Data that is exchanged across the processes should just be stream of bytes that both sender and receiver understands through a protocol.

    I'm taking a wild guess and suppose my ILogDroidSession implementation should also implement Parcelable, but that wouldn't work, because I can't parcel an object containg a reference to an SQLiteDatabase (or can I?).
    

    LogDroidSession can’t be parceled here, add new functions to ILogDroidBinder that returns session related information (in the form of plain data types).

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

Sidebar

Related Questions

I have looked at several tutorials using android and ksoap2. My service works fine
I've been using python for years, but I have little experience with python web
I am working on a little side project (program for Android platform)and I don't
I am new to android and only have a little experience with HTML and
i have a input tag which is non editable, but some times i need
My team is working on an Android project which consists of several Android applications
I'm trying to integrate Google Analytics into my Android project using the information on
I have a little/big problem in my app in android.I have 2 activity:Activity1 and
I am currently trying to implement some code using Android to detect when a
i have just started programming for android and i have a little question i

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.