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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:29:48+00:00 2026-05-22T23:29:48+00:00

I’ve created tab view and now I am trying to swich to again tab

  • 0

I’ve created tab view and now I am trying to swich to again tab after completion of task using intent, but the application forcefully closed. My error log is as below:

06-09 12:48:35.261: WARN/dalvikvm(439): threadid=3: thread exiting with uncaught exception (group=0x4001aa28)
06-09 12:48:35.261: ERROR/AndroidRuntime(439): Uncaught handler: thread main exiting due to uncaught exception
06-09 12:48:35.273: ERROR/AndroidRuntime(439): java.lang.NullPointerException
06-09 12:48:35.273: ERROR/AndroidRuntime(439):     at com.androidpeople.tab.MobiintheMorningActivity$HelloWebViewClient.onPageFinished(MobiintheMorningActivity.java:107)
06-09 12:48:35.273: ERROR/AndroidRuntime(439):     at android.webkit.CallbackProxy.handleMessage(CallbackProxy.java:222)
06-09 12:48:35.273: ERROR/AndroidRuntime(439):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-09 12:48:35.273: ERROR/AndroidRuntime(439):     at android.os.Looper.loop(Looper.java:123)
06-09 12:48:35.273: ERROR/AndroidRuntime(439):     at android.app.ActivityThread.main(ActivityThread.java:4203)
06-09 12:48:35.273: ERROR/AndroidRuntime(439):     at java.lang.reflect.Method.invokeNative(Native Method)
06-09 12:48:35.273: ERROR/AndroidRuntime(439):     at java.lang.reflect.Method.invoke(Method.java:521)
06-09 12:48:35.273: ERROR/AndroidRuntime(439):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
06-09 12:48:35.273: ERROR/AndroidRuntime(439):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:549)
06-09 12:48:35.273: ERROR/AndroidRuntime(439):     at dalvik.system.NativeStart.main(Native Method)
06-09 12:48:35.293: INFO/Process(52): Sending signal. PID: 439 SIG: 3
06-09 12:48:35.293: INFO/dalvikvm(439): threadid=7: reacting to signal 3
06-09 12:48:35.332: INFO/dalvikvm(439): Wrote stack trace to '/data/anr/traces.txt'
06-09 12:48:35.502: INFO/System.out(439): #: 2
06-09 12:48:35.502: WARN/dalvikvm(439): threadid=31: thread exiting with uncaught exception (group=0x4001aa28)
06-09 12:48:35.523: ERROR/AndroidRuntime(439): Uncaught handler: thread  exiting due to uncaught exception
06-09 12:48:35.523: ERROR/AndroidRuntime(439): java.lang.NullPointerException
06-09 12:48:35.523: ERROR/AndroidRuntime(439):     at com.androidpeople.tab.MobiintheMorningActivity$t2.run(MobiintheMorningActivity.java:218)
06-09 12:48:35.523: ERROR/AndroidRuntime(439):     at java.lang.Thread.run(Thread.java:1060)
06-09 12:48:35.543: INFO/Process(52): Sending signal. PID: 439 SIG: 3
06-09 12:48:35.543: WARN/ActivityManager(52): Process com.androidpeople.tab has crashed too many times: killing!
06-09 12:48:35.552: INFO/dalvikvm(439): threadid=7: reacting to signal 3
06-09 12:48:35.552: INFO/dalvikvm(439): Wrote stack trace to '/data/anr/traces.txt'
06-09 12:48:35.602: INFO/Process(52): Sending signal. PID: 439 SIG: 9
06-09 12:48:35.683: INFO/WindowManager(52): WIN DEATH: Window{4394ce88 com.androidpeople.tab/com.androidpeople.tab.CopyOfTabBarExample paused=true}
06-09 12:48:45.592: WARN/ActivityManager(52): Launch timeout has expired, giving up wake lock!

When I am trying find error from log it shows me this line.

My full code:

package com.androidpeople.tab;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.Toast;

public class activityname extends Activity {
    /**
     *================== VARIABLE AND CONTROL DECLARATION========
     */
    public static final int DIALOG_DOWNLOAD_PROGRESS = 0;
    ProgressBar myProgressBar;
    int myProgress = 0;
    private static final String LOG_TAG = "Test";
    final Context myApp = this;
    private WebView mWebView;
    Button btn, btn1;
    /**
     * ==================== URL =================================
     */
    private static final String strURL = "http://www.myURL";
    /**
     * ========================================================================
     * ==
     */
    final Activity activity = this;

    /**
     *========END OF VARIABLE AND CONTROL DECLARATION==============
     */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.mainforload);
        Button btn=(Button) findViewById(R.id.My_btn);
        mWebView = (WebView) findViewById(R.id.webviewHelp);
        mWebView.getSettings().setJavaScriptEnabled(true);
        mWebView.addJavascriptInterface(new MyjavascriptInterface(), "HTMLOUT");
        mWebView.loadUrl(strURL);
        mWebView.setWebViewClient(new HelloWebViewClient());
    }
    /**
     * 
     * =================THIS IS USED FOR GETTING SOURCE CODE===================
     * 
     */
    public class MyjavascriptInterface {
        public void showHTML(String html) {
            try {
                String struniqID = "<div id=\"uniqueid\">";
                mWebView = (WebView) findViewById(R.id.webviewHelp);    

                if (html.toString().contains(struniqID)) {
                    GlobalVariable.SetTemp(1);                  
                    String temp[] = html.toString().split(struniqID);
                    String strDiv = "</div>";                   
                    String temp1[] = temp[1].split(strDiv);
                    String strUidPswd = "&username=test&password=test";                 
                    String s = temp1[0].concat(strUidPswd);             
                    GlobalVariable.Setstr(s.toString());

                    try {
                        new Thread(new t(), "" + "").start();
                        // new temp().start();
                    } catch (Exception e) {

                    }
                } else {
                    GlobalVariable.SetTemp(0);
                    new Thread(new t2(), "" + "").start();

                }
            } catch (Exception e) {
                Log.i(LOG_TAG, e.toString() + "");
                Toast.makeText(myApp, e.toString(), Toast.LENGTH_LONG).show();
            }
        }
    }

    public class HelloWebViewClient extends WebViewClient {

        @Override
        public void onPageFinished(WebView view, String url) {
            view
                    .loadUrl("javascript:window.HTMLOUT.showHTML('<head>'+document.getElementsByTagName('html')[0].innerHTML+'</head>');");
            if (GlobalVariable.GetTemp() == 1) {
                final Button btn=(Button) findViewById(R.id.My_btn);
                btn.setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View arg0) {
                        try {
                            btn.requestFocus();

                            Intent i = new Intent(
                                    activityname.this,
                                    anotheractivityname.class);
                            finish();
                            startActivity(i);
//                          finish();

                        } catch (Exception e) {
                            Log.i(LOG_TAG, e.toString());
                        }
                    }
                });
            } else {
                btn = (Button) findViewById(R.id.My_btn);
                btn.requestFocus();
                btn.setVisibility(View.GONE);
            }

            super.onPageFinished(view, url);
        }

        @Override
        public boolean shouldOverrideKeyEvent(WebView view, KeyEvent event) {
            // TODO Auto-generated method stub
            if (GlobalVariable.GetTemp() == 1) {

            }
            return super.shouldOverrideKeyEvent(view, event);
        }

    }

    /**
     * ==============================THIS CLASS FOR DISPLAYING
     * BUTTON============================
     */
    class t implements Runnable {
        private int countDown = 2;

        public String toString() {
            return "#" + Thread.currentThread().getName() + ": " + countDown;
        }

        @Override
        public void run() {
            // TODO Auto-generated method stub
            while (true) {
                System.out.println(this);

                btn.post(new Runnable() {

                    @Override
                    public void run() {

                        // TODO Auto-generated method stub
                        if (GlobalVariable.GetTemp() == 1) {
                            btn.requestFocus();
                            btn.setVisibility(0);
                            // int i=0;
                            btn.setOnClickListener(new View.OnClickListener() {

                                @Override
                                public void onClick(View arg0) {
try{
                                    Intent i = new Intent(
                                            activityname.this,
                                            anotheractivity.class);
                                     finish();
                                    startActivity(i);

//                                   finish();
                                    }catch (Exception e) {
                                        // TODO: handle exception
                                    }
                                    // quit();
                                }
                            });
                        }
                        if (GlobalVariable.GetTemp() == 0) {
                            btn.requestFocus();
                            btn.setVisibility(4);
                        }
                    }
                });
                if (--countDown == 1)
                    return;
            }
        }
    }

    // =================================
    class t2 implements Runnable {
        private int countDown = 2;

        public String toString() {
            return "#" + Thread.currentThread().getName() + ": " + countDown;
        }

        @Override
        public void run() {
            // TODO Auto-generated method stub
            while (true) {
                System.out.println(this);
                btn.post(new Runnable() {

                    @Override
                    public void run() {
                        // TODO Auto-generated method stub
                        if (GlobalVariable.GetTemp() == 0) {
                            try{
                            btn.requestFocus();
                            btn.setVisibility(4);}catch (Exception e) {
                                // TODO: handle exception
                            }
                        }
                    }
                });
                if (--countDown == 1)
                    return;
            }
        }
    }

    /**
     * =========== THIS CUSTOM METHOD IS FOR CLOSING THE CURRENT EXECUTING
     * PROCESS===================
     */
    public void quit() {
        int pid = android.os.Process.myPid();
        android.os.Process.killProcess(pid);
        System.exit(0);

    }
}

and this is my tabbar file that extends TabActivity

/** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.maiin);
        final TabHost tabHost = (TabHost) getTabHost();
        try {
            tabHost.addTab(createTab(activityname.class, "Welcome",
                    "Welcome", R.drawable.tab_icon_events));
            tabHost.addTab(createTab(anotheractivityname.class, ".Mp3List", ".Mp3List",
                    R.drawable.tab_icon_pitchforkfm));
            tabHost.addTab(createTab(AboutUs.class, "AboutUs", "AboutUs",
                    R.drawable.tab_icon_home));
            tabHost.addTab(createTab(ExitActivity.class, "EXIT", "EXIT",
                    R.drawable.tab_icon_tv));

            tabHost.setCurrentTab(1);
        } catch (Exception e) {
            // TODO: handle exception
        }
        tabHost.getTabWidget().getChildAt(0).getLayoutParams().width = 85;
        tabHost.getTabWidget().getChildAt(1).getLayoutParams().width = 85;
        tabHost.getTabWidget().getChildAt(2).getLayoutParams().width = 85;
        tabHost.getTabWidget().getChildAt(3).getLayoutParams().width = 85;

    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            moveTaskToBack(false);

            return true;
        }
        return super.onKeyDown(keyCode, event);
    }

    private TabSpec createTab(final Class<?> intentClass, final String tag,
            final String title, final int drawable) 
    {
        final Intent intent = new Intent().setClass(this, intentClass);

        final View tab = LayoutInflater.from(getTabHost().getContext())
                .inflate(R.layout.tab, null);
        ((TextView) tab.findViewById(R.id.tab_text)).setText(title);
        ((ImageView) tab.findViewById(R.id.tab_icon))
                .setImageResource(drawable);

        return getTabHost().newTabSpec(tag).setIndicator(tab)
                .setContent(intent);

    }
}
  • 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-22T23:29:49+00:00Added an answer on May 22, 2026 at 11:29 pm

    You need to initialize the button in inside activity class , otherwise it won`t work , then use that button in WebViewClient class.

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,

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.