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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:20:54+00:00 2026-06-08T22:20:54+00:00

I want to start an activity, so I picked this Class way. I know

  • 0

I want to start an activity, so I picked this Class way. I know I can do it easily by passing ACTION NAME directly in intent constructor but I am learning android so I trying to learn new ways. I started another activity with the same code in other class and it working there but here it is giving the following error. I think it has to some thing with THREAD class.

The error is:

The constructor Intent(new Thread(){}, Class) is undefined. 

How can I solve this?
Here is the code:

package com.umer.practice2;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

public class SplashScreen extends Activity{

@Override
protected void onCreate(Bundle savedInstanceState) {
    // TODO Auto-generated method stub
    super.onCreate(savedInstanceState);
    setContentView(R.layout.splashscreen);

    Thread timer= new Thread()
    {
        public void run()
        {
        try
        {
            sleep(5000);
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
        finally
        {
            Class ourclass = Class.forName("com.umer.practice2.StartingPoint");
            Intent myintent= new Intent(this,ourclass); // error
            startActivity(myintent);
        }
        }
    };
    timer.start();
}

@Override
protected void onPause() {
    // TODO Auto-generated method stub
    super.onPause();
    finish();
}

}

Here is the layout of the class activity which is giving force close error.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TextView
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:hint="hint"
        android:id="@+id/fdisp" 
        />
    <Button
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="How many times you eat in a day"
        android:gravity="center"
        android:id="@+id/but3" 
        />


</LinearLayout>

and here is the code of the class itself

    package com.umer.practice2;

    import android.app.Activity;
    import android.os.Bundle;
    import android.view.View;
    import android.widget.Button;
    import android.widget.TextView;

    public class MyClass extends Activity{

    Button b3;
    TextView disp;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        // TODO Auto-generated method stub
        super.onCreate(savedInstanceState);
         b3= (Button) findViewById(R.id.but3);
         disp= (TextView) findViewById(R.id.fdisp);

         b3.setOnClickListener(new View.OnClickListener() {

             @Override
            public void onClick(View arg0) {
                // TODO Auto-generated method stub
                    disp.setText("It depends ");
            }
        });
    }
    }
  • 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-08T22:20:55+00:00Added an answer on June 8, 2026 at 10:20 pm

    Just replace the intent creation by:

    Intent myintent= new Intent(SplashScreen.this, StartingPoint.class);
    

    Otherwise, this refers to the enclosing Thread class

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

Sidebar

Related Questions

Normally, if I want to start a new activity I can use StartActivity(typeof(foo)); This
In my apps menu class I want a button to start an activity. This
Whenewer I want to start new activity, I use this code: Intent myIntent1 =
I have an activity. In this activity I want to start another activity using
I need to start an Activity with two different Intent, can I define two
Is there a way to start an activity from a view? I have this
I'm looking for the best way to start an intent from a class that
I want to start a new activity intent in my current view! How i
I want to start camera activity in my android app and I know how
I want to start multiple instance of the same Activity class from a Service

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.