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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:13:14+00:00 2026-06-11T13:13:14+00:00

I’m developing an application. This application contains 2 classes Discovery class which implements serializable

  • 0

I’m developing an application.

This application contains 2 classes

  • Discovery class which implements serializable

  • Main class which extends Activity

In the Main class I call the android web browser on a click on the button in the application interface . And this behaviour generate a crash.

bellow is the code:

MainTest.java

package com.heeere.androiddnssd.discovery;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class MainTest extends Activity {

    android.net.wifi.WifiManager.MulticastLock lock;
    private Discovery discovery; 
    private TextView textView;

    /** Called when the activity is first created. */

    @SuppressLint("NewApi") @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        if ( savedInstanceState == null)
            discovery = new Discovery(this);
        else
            discovery = (Discovery) savedInstanceState.getSerializable("discovery");
        setContentView(R.layout.main);
        textView = (TextView)this.findViewById(R.id.text);
        Button b = (Button)this.findViewById(R.id.button);
        b.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                //discovery.setUp();
                Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
                startActivity(browserIntent);
            }
        });

        android.net.wifi.WifiManager wifi = (android.net.wifi.WifiManager) getSystemService(android.content.Context.WIFI_SERVICE);
        lock = wifi.createMulticastLock("mylockthereturn");
        lock.setReferenceCounted(true);
        lock.acquire();

    }

    @Override
    protected void onSaveInstanceState(final Bundle outState) {
        outState.putSerializable("discovery", discovery);
        super.onSaveInstanceState(outState);
    }

    public void updateView () {
        String msg = discovery.getMsg();
        textView.setText(msg);
    }


    @SuppressLint("NewApi") @Override
    protected void onStop() {
        discovery.stop();
        lock.release();
        super.onStop();
    }


}

Discovery.java

package com.heeere.androiddnssd.discovery;

import java.io.IOException;
import java.io.Serializable;

import javax.jmdns.JmDNS;
import javax.jmdns.ServiceEvent;
import javax.jmdns.ServiceListener;

public class Discovery implements Serializable {


    private static final long serialVersionUID = 637576886455091135L;
    private String type = "_ikunet._tcp.local.";
    private String msg="";
    private JmDNS jmdns = null;
    private ServiceListener listener = null;
    private MainTest maintest;
    android.os.Handler handler = new android.os.Handler();

    public Discovery (MainTest maintest) {
        this.maintest = maintest;
        setUp();
    }

    public void setUp() {

        try {
            jmdns = JmDNS.create();
            jmdns.addServiceListener(type, listener = new ServiceListener() {

                public void serviceResolved(ServiceEvent ev) {
                    msg = msg + ev.getInfo().getName()+ "\n";
                    update();
                }

                public void serviceRemoved(ServiceEvent ev) {
                }

                public void serviceAdded(ServiceEvent event) {
                    jmdns.requestServiceInfo(event.getType(), event.getName(), 1);
                }
            });
        } catch (IOException e) {
            //e.printStackTrace();
            return;
        }
    }

    public String getMsg() {
        return msg;
    }

    private void update() {
        handler.postDelayed(new Runnable() {
            public void run() {
                maintest.updateView();
            }
        }, 1);
    }


    public void stop() {
        if (jmdns != null) {
            if (listener != null) {
                jmdns.removeServiceListener(type, listener);
                listener = null;
            }
            jmdns.unregisterAllServices();
            try {
                jmdns.close();
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            jmdns = null;
        }
    }

}

LogCat

09-13 15:08:30.507: E/AndroidRuntime(15775): Uncaught handler: thread main exiting due to uncaught exception
09-13 15:08:30.517: E/AndroidRuntime(15775): java.lang.RuntimeException: Parcelable encountered IOException writing serializable object (name = com.heeere.androiddnssd.discovery.Discovery)
09-13 15:08:30.517: E/AndroidRuntime(15775):    at android.os.Parcel.writeSerializable(Parcel.java:1131)
09-13 15:08:30.517: E/AndroidRuntime(15775):    at android.os.Parcel.writeValue(Parcel.java:1085)
09-13 15:08:30.517: E/AndroidRuntime(15775):    at android.os.Parcel.writeMapInternal(Parcel.java:469)
09-13 15:08:30.517: E/AndroidRuntime(15775):    at android.os.Bundle.writeToParcel(Bundle.java:1445)
09-13 15:08:30.517: E/AndroidRuntime(15775):    at android.os.Parcel.writeBundle(Parcel.java:483)
09-13 15:08:30.517: E/AndroidRuntime(15775):    at android.app.ActivityManagerProxy.activityPaused(ActivityManagerNative.java:1427)
09-13 15:08:30.517: E/AndroidRuntime(15775):    at android.app.ActivityThread.handlePauseActivity(ActivityThread.java:3106)
09-13 15:08:30.517: E/AndroidRuntime(15775):    at android.app.ActivityThread.access$2400(ActivityThread.java:119)
09-13 15:08:30.517: E/AndroidRuntime(15775):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1870)
09-13 15:08:30.517: E/AndroidRuntime(15775):    at android.os.Handler.dispatchMessage(Handler.java:99)
09-13 15:08:30.517: E/AndroidRuntime(15775):    at android.os.Looper.loop(Looper.java:123)
09-13 15:08:30.517: E/AndroidRuntime(15775):    at android.app.ActivityThread.main(ActivityThread.java:4363)
09-13 15:08:30.517: E/AndroidRuntime(15775):    at java.lang.reflect.Method.invokeNative(Native Method)
09-13 15:08:30.517: E/AndroidRuntime(15775):    at java.lang.reflect.Method.invoke(Method.java:521)
09-13 15:08:30.517: E/AndroidRuntime(15775):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
09-13 15:08:30.517: E/AndroidRuntime(15775):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
09-13 15:08:30.517: E/AndroidRuntime(15775):    at dalvik.system.NativeStart.main(Native Method)
09-13 15:08:30.517: E/AndroidRuntime(15775): Caused by: java.io.NotSerializableException: android.os.Handler
09-13 15:08:30.517: E/AndroidRuntime(15775):    at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1547)
09-13 15:08:30.517: E/AndroidRuntime(15775):    at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1854)
09-13 15:08:30.517: E/AndroidRuntime(15775):    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1696)
09-13 15:08:30.517: E/AndroidRuntime(15775):    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1660)
09-13 15:08:30.517: E/AndroidRuntime(15775):    at java.io.ObjectOutputStream.writeFieldValues(ObjectOutputStream.java:1153)
09-13 15:08:30.517: E/AndroidRuntime(15775):    at java.io.ObjectOutputStream.defaultWriteObject(ObjectOutputStream.java:420)
09-13 15:08:30.517: E/AndroidRuntime(15775):    at java.io.ObjectOutputStream.writeHierarchy(ObjectOutputStream.java:1251)
09-13 15:08:30.517: E/AndroidRuntime(15775):    at java.io.ObjectOutputStream.writeNewObject(ObjectOutputStream.java:1587)
09-13 15:08:30.517: E/AndroidRuntime(15775):    at java.io.ObjectOutputStream.writeObjectInternal(ObjectOutputStream.java:1854)
09-13 15:08:30.517: E/AndroidRuntime(15775):    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1696)
09-13 15:08:30.517: E/AndroidRuntime(15775):    at java.io.ObjectOutputStream.writeObject(ObjectOutputStream.java:1660)
09-13 15:08:30.517: E/AndroidRuntime(15775):    at android.os.Parcel.writeSerializable(Parcel.java:1126)
09-13 15:08:30.517: E/AndroidRuntime(15775):    ... 16 more
  • 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-11T13:13:15+00:00Added an answer on June 11, 2026 at 1:13 pm

    the problem is due to pass main activity to serializable class when creating its related object. in our case passing the MainTest Object to the Discovery object when creating it.
    The solution: create another serializable class which contains all Discovery data (data to be serialzable).

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am doing a simple coin flipping experiment for class that involves flipping 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.