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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:24:23+00:00 2026-05-26T13:24:23+00:00

So this is probably an easy thing that I’m trying to do but I’m

  • 0

So this is probably an easy thing that I’m trying to do but I’m trying to get the default android loading screen to show and have the text instead say “Consuming…” I’m doing this based off the tutorial in the Android Cookbook. Here are my code and xml files. If you need any other bits of code, just let me know. I honestly am probably doing something stupid but I just need to know. There is nothing happening in logcat so I’m sure what the issue is. Though, the book may just be outdated. I should also note that I’m running of Android 2.2 and I’m testing on a Samsung Galaxy 4G.

So I guess a bit more info is needed. I’m trying to follow the Handling a Time-Consuming Initialization recipe in the Android Developer’s Cookbook: http://bit.ly/sFoBn6
I just want a simple text splash screen. Not even a progress bar. We’re talking simple stupid right now. I’m still learning Android. I just want it to do the normal “Loading..” but instead have it say “Consuming…”

HandleMessage.java

package com.cookbook.handle_message;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.widget.TextView;

public class HandleMessage extends Activity implements Runnable {
    /** Called when the activity is first created. */
    TextView mTestLabel;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        mTestLabel = (TextView) findViewById(R.id.test);

        Thread thread = new Thread(this);
        thread.start();
    }

    private Handler mHandler = new Handler() {
        public void handleMessage(Message msg) {
            setContentView(R.layout.main);
        }
    };

    public void run() {
        initializeArrays();
        mHandler.sendEmptyMessage(0);
    }

    final static int NUM_SAMPS = 1000;
    static double[][] correlation;

    void initializeArrays() {
        if(correlation!=null) return;

        correlation = new double[NUM_SAMPS][NUM_SAMPS];
        for(int k=0; k<NUM_SAMPS; k++){
            for(int m=0; m<NUM_SAMPS; m++){
                correlation[k][m] = Math.cos(2*Math.PI*(k+m)/1000);
            }
        }
    }
}

res/layout/main.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="fill_parent"
    android:orientation="vertical" >


    <TextView
        android:id="@+id/test"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hello" />

</LinearLayout>

res/layout/loading.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="fill_parent">

    <TextView android:id="@+id/loading"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="Consuming..."/>
</LinearLayout>

AndroidManifest.xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.cookbook.handle_message"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk android:minSdkVersion="8" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:label="@string/app_name"
            android:name=".HandleMessage" >
            <intent-filter >
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>
  • 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-26T13:24:24+00:00Added an answer on May 26, 2026 at 1:24 pm

    Maybe you just want a progress indicator or something? See this page for an example that shows how to start an activity with a long running thread that updates the progress bar as it goes along.

    Also, you indicated LogCat says nothing. Put some Log.i statements in your code to see what’s going on.

    EDIT: Ok, in your code above, don’t use 2 layouts. Use just 1. Then in your handler change the text of the textview.

    So if you use loading.xml, set that in onCreate and then in your handler just do something like:

     public void handleMessage(Message msg) {
            TextView tv=(TextView)findViewById(R.id.loading);
            tv.setText("All Done");
        }
    

    Get it? Definitely don’t call setContentView twice for this kind of thing. There may be a way to do that, so maybe it has its uses, but I’ve never done it. Also, as a side note, I’ve started using AsyncTask instead of threads and Handlers for some stuff.

    Also, whenever something isn’t working, please add Log statements so that you can tell what’s going on.

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

Sidebar

Related Questions

This is probably easy, but I'm trying to convert from a source which provides
Ok, I think this is probably an easy question but for the life of
I've been working all day and I somehow can't get this probably easy task
This is probably easy but I am getting stuck: when I build a solution
This is probably an easy question, but I want to understand better how Apache
This is probably really easy but I can't seem to figure out how to
This is probably seriously easy to solve for most of you but I cannot
This is probably really easy, but I'm lost on how to make sure it
This is probably an easy question... I have 4 source versions of the same
Morning y'all This is probably an easy one but I barely got any sleep

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.