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 4230488
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T01:52:17+00:00 2026-05-21T01:52:17+00:00

So, Here is my scenario: I have two activity and one service –> all

  • 0

So, Here is my scenario:
I have two activity and one service –> all three(classes) requires a return type value from another service(so total 2 activity, 2 service in the application).

i.e:
Activity A, starts –> an Activity B and a Service I.

Activity B, starts –> a Service II.

Thereafter, Activity A, B and Service II has to communicate with Service I.
Service I is always running behind and never stops once started.

My approach of doing that was as follows:

  1. Write three .aidl files that declares the interface between the four communicating classes.

  2. Create Activity A, then create Service I, Activity B;and from Activity B create Service II.

  3. As Service I can have only one onBind() method, for communicating with the 3 classes at any time, what i’m doing is that all intent from 3 classes are differentiated by assigning different value using setType() property.

  4. Connection is built between each two classes when communication has to be done using initService() and released soon after that using releaseService().

  5. At Service I, the onBind() method has to first check from which of the 3 classes the intent is coming, using getType() property, and return the respective IBinder type.

Now,
my problem is at step 5. in which the onBind() method can’t perform the operation of checking the getType() of every intents and give the respective return type.
Here is my code, for onBinder() method in Service I:

@Override
public IBinder onBind(final Intent intent){
    Log.d(Main_Service.TAG,"it got connected");
    if(intent.getType=="Activity_A")
    {
        return new Activity_A_aidl.Stub() {
            public void function1(int u1,String p1,String p2) throws RemoteException{
                //do something
            }
        };}

    if(intent.getType=="Activity_B"){
        return new Activity_B_aidl.Stub() {
            public int function2() throws RemoteException{//do something
                return some_integer_values;
            }
        };} 
    if(intent.getType()="Service_II"){
        return new Service_II_aidl.Stub(){
            public boolean function3(String u,String p) throws RemoteException{
                //do something

            return boolean_type_variable;
            }
        };}
}

error: as show in LogCat: java.lang.NullPointerException

from all 3 classes(Activity A,B & Service II) where-ever i’m calling one of the functions within try-catch block.

Can anyone tell me where am i going wrong.

-Kishore Debnath, (3rd yr, CSE Student).

  • 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-21T01:52:17+00:00Added an answer on May 21, 2026 at 1:52 am

    Without commenting on your overall design, I would add that the way for the service to differentiate between callers is to use the ‘action’ property. I don’t know what initService() is but when I bind to a remote service, I simply use bindService(). So in your activities have something like:

    bindService(new Intent("com.mypackage.myService.ACTION_1"), this,
                    Context.BIND_AUTO_CREATE);
    

    or .ACTION_2 or .ACTION_3.

    Then in your services manifest have an intent filter:

    <intent-filter>
       <action  android:name="com.mypackage.myService.ACTION_1" />
       <action  android:name="com.mypackage.myService.ACTION_2" />
       <action  android:name="com.mypackage.myService.ACTION_3" />
    </intent-filter>
    

    Then in the service’s onBind(), use intent.getAction() to return a String, identifying the caller. (Use the proper .equals() method to match the String!) and return the appropriate IBinder

    I don’t think extras on the Intent get passed through to the service. I’ve never bound to service from another service but I suppose it might work.

    As a final point, I only use AIDL and a remote service because for commercial reasons I need the functionality to be split between two separate .apks. There is no good technical reason for me to use it, in fact quite the opposite.

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

Sidebar

Related Questions

Here is the scenario: You have two images and they are stacked on one
Here is the scenario: I have two asp pages. a.aspx is layout and b.aspx
Here's my scenario: I have two web applications that are hosted on seperate servers.
Here is the scenario: I have two radio buttons, 1) for a normal customers
Here's my scenario: I have two tables A, B which (for the sake of
Here's the scenario: You have two seperate websites that exist in different environments (I.E.
Classic ASP Request.ServerVariables(LOGON_USER) is returning wrong username. Here is the scenario: I have two
Here is the scenario: I have successfully bound two objects from a native ObjC
Here's my scenario: I have a page containing several links; each link is meant
I have ran into quite an interesting mapping scenario. I have two entities (

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.