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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:52:24+00:00 2026-06-03T09:52:24+00:00

I created a service which sends commands to an external activity through AIDL: after

  • 0

I created a service which sends commands to an external activity through AIDL: after this activity bind to the service, it sends a callback to the service, and so a two-way communication is established and works correctly.

Instead, the problem arises when I want to change the UI of the application according to commands received from the service. I performed a test with a simple Toast notification, but some errors occur…

The onExecute method of the external activity is called when a new command is received through AIDL. If I remove the Toast notification, everything is working properly, but I need to change the UI according to commands received from the service.

protected void onExecute(Bundle params) {
    Log.i(LOG_TAG, "onExecute(): " + params);

    if (params.containsKey("command01")) {
        Log.i(LOG_TAG, "onExecute(): " + params.getString("command01"));
        Toast
        .makeText(this, "Command 1...", Toast.LENGTH_SHORT)
        .show();
    }
    else if (params.containsKey("command02")) {
        Log.i(LOG_TAG, "onExecute(): " + params.getString("command02"));
        Toast
        .makeText(this, "Command 2...", Toast.LENGTH_SHORT)
        .show();
    }
    else {
        Log.w(LOG_TAG, "onExecute() - unknown command: " + params);
    }
}

Below is shown the log recorded by LogCat during the error:

05-07 12:45:30.676: W/dalvikvm(363): JNI WARNING: JNI method called with exception raised
05-07 12:45:30.676: W/dalvikvm(363):              in Ldalvik/system/NativeStart;.run ()V (CallStaticVoidMethodV)
05-07 12:45:30.676: W/dalvikvm(363): Pending exception is:
05-07 12:45:30.676: I/dalvikvm(363): Ljava/lang/RuntimeException;: Can't create handler inside thread that has not called Looper.prepare()
05-07 12:45:30.706: I/dalvikvm(363):    at android.os.Handler.<init>(Handler.java:121)
05-07 12:45:30.706: I/dalvikvm(363):    at android.widget.Toast.<init>(Toast.java:68)
05-07 12:45:30.706: I/dalvikvm(363):    at android.widget.Toast.makeText(Toast.java:231)
05-07 12:45:30.706: I/dalvikvm(363):    at org.example.android.applicationdemo.ApplicationDemoActivity.onExecute(ApplicationDemoActivity.java:130)
05-07 12:45:30.706: I/dalvikvm(363):    at org.example.android.applicationdemo.ApplicationDemoActivity$2.execute(ApplicationDemoActivity.java:100)
05-07 12:45:30.706: I/dalvikvm(363):    at org.example.android.servicedemo.IServiceCallback$Stub.onTransact(IServiceCallback.java:55)
05-07 12:45:30.706: I/dalvikvm(363):    at android.os.Binder.execTransact(Binder.java:320)
05-07 12:45:30.706: I/dalvikvm(363):    at dalvik.system.NativeStart.run(Native Method)
05-07 12:45:30.706: I/dalvikvm(363): "Binder Thread #2" prio=5 tid=8 NATIVE
05-07 12:45:30.706: I/dalvikvm(363):   | group="main" sCount=0 dsCount=0 obj=0x405116f0 self=0x1f1590
05-07 12:45:30.706: I/dalvikvm(363):   | sysTid=370 nice=0 sched=0/0 cgrp=default handle=2037072
05-07 12:45:30.714: I/dalvikvm(363):   | schedstat=( 18375041 37002039 19 )
05-07 12:45:30.714: I/dalvikvm(363):   at dalvik.system.NativeStart.run(Native Method)
05-07 12:45:30.714: E/dalvikvm(363): VM aborting
  • 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-06-03T09:52:25+00:00Added an answer on June 3, 2026 at 9:52 am

    I think you create your Handler inside a method executed on a non-UI thread.
    Make your Handler as a global variable.

    private Handler _handler = new Handler();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We've developed a service, which sends e-mails... quite trivial at this step. The next
My application consists of two part: a web service, which sends queues to a
I have created a web service which is saving some data into to db.
I have created a web service which takes a username and password as parameters
I have created a web service which returns some data and am trying to
I am a WCF / Security Newb. I have created a WCF service which
I created an .asmx web service which i call via Ajax. i used the
I created a simple .Net web service which runs a very simple query (which
I'm using a web service which returns a list of products. I created a
I've created a [WebMethod] on ASP.NET Web Service which reads XML documents from different

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.