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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:34:47+00:00 2026-05-17T23:34:47+00:00

Here’s my error: *** Uncaught remote exception! (Exceptions are not yet supported across processes.)

  • 0

Here’s my error:

*** Uncaught remote exception!  (Exceptions are not yet supported across processes.)
android.util.AndroidRuntimeException: { what=1008 when=368280372 } This message is already in use.
at android.os.MessageQueue.enqueueMessage(MessageQueue.java:171)
at android.os.Handler.sendMessageAtTime(Handler.java:457)
at android.os.Handler.sendMessageDelayed(Handler.java:430)
at android.os.Handler.sendMessage(Handler.java:367)
at android.view.ViewRoot.dispatchAppVisibility(ViewRoot.java:2748)

What I’m attempting is to have a listview, that is populated by custom list items, each list item has multiple views and each view has an onclick listener attached. When this onClickListener is pressed it sends a Message to a Handler with a what and arg1 arguments.
Clicking one of my elements fires an intent to start a new activity.
Clicking the other shows a toast.
When these are pressed in a combination I get the error above. Namely clicking the text to fire the intent, (then press back) then clicking the image to show the toast, then when you click the text to fire the intent again I get the FC.

And here is the code below, I tried to remove as much cruft as I could to get to the bones of the error:

If you want to skip to whats important look at the onClickListener’s in ConversationAdapter.class and how they interact with StartPage.class

Android Manifest:

<?xml version="1.0" encoding="utf-8"?>
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.handler.test"
    android:versionCode="1"
    android:versionName="1.0">
      <application android:icon="@drawable/icon" android:label="@string/app_name">
        <activity android:name=".StartPage"
              android:label="@string/app_name">
            <intent-filter>
              <action android:name="android.intent.action.MAIN" />
              <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    <activity
        android:name=".DetailsPage"
        android:label="DetailsPage"
        >
    </activity> 
    </application>
    <uses-sdk android:minSdkVersion="3" />
</manifest>

StartPage.class:

package com.handler.test;

import java.util.ArrayList;

import android.app.ListActivity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.widget.Toast;

public class StartPage extends ListActivity {

private ArrayList<Conversation> mConversations = null;
private ConversationAdapter mAdapter;
private Context mContext;
private ProgressDialog mProgressDialog;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    mContext = this;

    mConversations = new ArrayList<Conversation>();
    this.mAdapter = new ConversationAdapter(mContext, R.layout.inbox_row, mConversations, mHandler);
    setListAdapter(this.mAdapter);

    new Thread(new Runnable() {
        @Override
        public void run() {
            getConversations();
        }
    }).start();

    mProgressDialog = ProgressDialog.show(StartPage.this, "Please wait...", "Retrieving data ...", true);
}

private void getConversations() {
    try {
        mConversations = new ArrayList<Conversation>();
        Conversation o1 = new Conversation();
        o1.setStatus("SF services");
        o1.setMessage("Pending");           
        mConversations.add(o1);
    } catch (Exception e) {
        Log.e("BACKGROUND_PROC", e.getMessage());
    }
    runOnUiThread(returnRes);
}

private Runnable returnRes = new Runnable() {
    @Override
    public void run() {
        if(mConversations != null && mConversations.size() > 0){
            mAdapter.notifyDataSetChanged();
            for(int i=0;i<mConversations.size();i++)
                mAdapter.add(mConversations.get(i));
        }
        mProgressDialog.dismiss();
        mAdapter.notifyDataSetChanged();
    }
  };

private Handler mHandler = new Handler(){
    @Override
    public void handleMessage(Message msg) {
        int convIndex = msg.arg1;
        int viewTouched = msg.what;
        switch(viewTouched){
            case ConversationAdapter.PROF_ICON:
                showNumber(convIndex);
            break;
            case ConversationAdapter.MESSAGE:
                showMessageDetails(convIndex);
            break;
        }
        super.handleMessage(msg);
    }
};

private void showNumber(int convIndex) {
    Toast.makeText(mContext, "Pressed: "+convIndex, Toast.LENGTH_LONG).show();
}

private void showMessageDetails(int convIndex) {
    final Conversation conv = mConversations.get(convIndex);
    Intent i = new Intent(mContext, DetailsPage.class);
    i.putExtra("someExtra", conv);
    startActivity(i);
}
}

DetailsPage.class

package com.handler.test;

import android.app.Activity;
import android.os.Bundle;
import android.util.Log;

public class DetailsPage extends Activity {


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    Log.i("Test", "Details Page");      
}


}

Conversation.class:

package com.handler.test;

import java.io.Serializable;

public class Conversation implements Serializable {

private static final long serialVersionUID = -437261671361122258L;

private String status;

public String getStatus() {
    return status;
}
public void setStatus(String status) {
    this.status = status;
}
}

ConversationAdapter.class:

package com.handler.test;

import java.util.ArrayList;

import android.content.Context;
import android.os.Handler;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;

public class ConversationAdapter extends ArrayAdapter<Conversation> {

public static final int PROF_ICON = 0;
public static final int MESSAGE = 1;

private Context mContext;
private Handler mHandler;
private ArrayList<Conversation> mItems;
private int mXmlId;

private LinearLayout detailsOfConv;
private ImageView iconImage;

public ConversationAdapter(Context context, int textViewResourceId, ArrayList<Conversation> items, Handler handler) {
    super(context, textViewResourceId, items);
    this.mContext = context;
    this.mItems = items;
    this.mXmlId = textViewResourceId;
    this.mHandler = handler;
}

@Override
public View getView(int position, View convertView, ViewGroup parent) {
    View v = convertView;
    if (v == null) {
        LayoutInflater vi = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        v = vi.inflate(mXmlId, null);
    }
    final Message m = new Message();
    m.arg1 = position;
    Conversation c = mItems.get(position);
    if (c != null) {
        iconImage = (ImageView) v.findViewById(R.id.icon);
        if (iconImage != null) {
            iconImage.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    m.what = PROF_ICON;
                    mHandler.sendMessage(m);
                }
            });
        }

        detailsOfConv = (LinearLayout) v.findViewById(R.id.details);
        if(detailsOfConv != null){
            detailsOfConv.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    m.what = MESSAGE;
                    mHandler.sendMessage(m);
                }
            });
        }
    }
    return v;
}
}

main.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="10dip"
>
<ListView
 android:id="@+id/android:list"
 android:layout_width="wrap_content"
 android:layout_height="wrap_content"
 android:cacheColorHint="#00000000"
 />
</LinearLayout>

inbox_row.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="?android:attr/listPreferredItemHeight"
  android:padding="6dip">
  <ImageView
    android:id="@+id/icon"
    android:layout_width="wrap_content"
    android:layout_height="fill_parent"
    android:layout_marginRight="6dip"
    android:src="@drawable/icon" />
  <LinearLayout
    android:id="@+id/details"
    android:orientation="vertical"
    android:layout_width="0dip"
    android:layout_weight="1"
    android:layout_height="fill_parent">
    <TextView
        android:id="@+id/toptext"
        android:textColor="#99FF66"
        android:layout_width="fill_parent"
        android:layout_height="0dip"
        android:layout_weight="1"
        android:singleLine="true"
        android:text="123456789"
        />       
  </LinearLayout>
</LinearLayout>
  • 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-17T23:34:47+00:00Added an answer on May 17, 2026 at 11:34 pm

    My guess would be that you are sending twice the same message. Indeed in the code there is one new Message() and two mHandler.sendMessage(m) which are possibly both executed.

    Try making a new message for every time you send a message.

    Edited:

    Message.obtain() is preferable to Message m = new Message() (because it recycles used messages under the hood)

    In your case you could use new.copyFrom(old) if you need a copy of existing message.

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

Sidebar

Related Questions

Here's a basic regex technique that I've never managed to remember. Let's say I'm
Here's a problem I ran into recently. I have attributes strings of the form
Here is the issue I am having: I have a large query that needs
Here's my scenario - I have an SSIS job that depends on another prior
Here is a simplification of my database: Table: Property Fields: ID, Address Table: Quote
Here is my code, which takes two version identifiers in the form 1, 5,
Here's a coding problem for those that like this kind of thing. Let's see
Here is the scenario: I'm writing an app that will watch for any changes
Here's an interesting problem. On a recently installed Server 2008 64bit I opened IE
Here we go again, the old argument still arises... Would we better have a

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.