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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T07:57:25+00:00 2026-06-16T07:57:25+00:00

I’m trying to test if my android app works, it consists of 2 activity

  • 0

I’m trying to test if my android app works, it consists of 2 activity screens. There are no errors in my codes but my app won’t run. It always gives me this error on the emulator “Unfortunately ‘application name’ has stopped.”

Here is my Activity code

    public class MainActivity extends Activity
{

        @Override
        public void onCreate(Bundle savedInstanceState)
        {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            View title = getWindow().findViewById(android.R.id.title);
            View titleBar = (View) title.getParent();
            titleBar.setBackgroundColor(Color.RED);
            Button next=(Button)findViewById(R.id.DGButton);
            next.setOnClickListener(new View.OnClickListener() {
                public void onClick(View view) {
                    Intent myIntent=new Intent(view.getContext(), 

    Activity2.class);
                    startActivityForResult(myIntent, 0);
                }});}

        public void calculateClickHandler(View view)
        {
            if (view.getId() == R.id.CalculateButton)
            {
                EditText ageText = (EditText)findViewById

    (R.id.AgeField);
                EditText weightText = (EditText)findViewById

    (R.id.WeightField);
                EditText ftText = (EditText)findViewById

    (R.id.HeightField);
                EditText inText = (EditText)findViewById

    (R.id.HeightField2);
                RadioGroup weightRG = (RadioGroup) findViewById

    (R.id.WeightRG);
                RadioGroup sexRG = (RadioGroup) findViewById

    (R.id.SexRG);

                TextView resultText = (TextView)findViewById

    (R.id.ResultLabel);
                TextView normalBMIText = (TextView)findViewById

    (R.id.NormalBMI);
                TextView idealKgText = (TextView)findViewById

    (R.id.IdealKgLabel);
                TextView idealLbText = (TextView)findViewById

    (R.id.IdealLbLabel);
                int age = Integer.parseInt(ageText.getText

    ().toString());
                double weight = Double.parseDouble

    (weightText.getText().toString());
                double ftheight = Double.parseDouble(ftText.getText

    ().toString());
                double inheight = Double.parseDouble(inText.getText

    ().toString());
                int checkedRadioButton1 = 

    weightRG.getCheckedRadioButtonId();
                int checkedRadioButton2 = 

    sexRG.getCheckedRadioButtonId();

                double bmiValue = calculateBMI(weight, ftheight, 

    inheight, checkedRadioButton1);
                String bmiInterpretation1 = interpretBMI1(bmiValue);
                String bmiInterpretation2 = interpretBMI2(age);
                String bmiInterpretation3 = interpretBMI3(ftheight, 

    inheight, checkedRadioButton2);
                String bmiInterpretation4 = interpretBMI4(ftheight, 

    inheight, checkedRadioButton2);

                resultText.setText(bmiValue + " - " + 

    bmiInterpretation1);
                normalBMIText.setText(""+bmiInterpretation2);
                idealKgText.setText(""+bmiInterpretation3);
                idealLbText.setText(""+bmiInterpretation4);

                Intent intent1 = new Intent(MainActivity.this, 

    Activity2.class);
                Bundle b = new Bundle();
                b.putDouble("key", bmiValue);
                intent1.putExtras(b);
                startActivity(intent1);
    }}

This is the error logcat:

12-26 02:50:45.606: E/AndroidRuntime(1776): FATAL EXCEPTION: main
12-26 02:50:45.606: E/AndroidRuntime(1776): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.bmicaldg/com.example.bmicaldg.MainActivity}: java.lang.NullPointerException
12-26 02:50:45.606: E/AndroidRuntime(1776):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
12-26 02:50:45.606: E/AndroidRuntime(1776):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
12-26 02:50:45.606: E/AndroidRuntime(1776):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
12-26 02:50:45.606: E/AndroidRuntime(1776):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
12-26 02:50:45.606: E/AndroidRuntime(1776):     at android.os.Handler.dispatchMessage(Handler.java:99)
12-26 02:50:45.606: E/AndroidRuntime(1776):     at android.os.Looper.loop(Looper.java:137)
12-26 02:50:45.606: E/AndroidRuntime(1776):     at android.app.ActivityThread.main(ActivityThread.java:5039)
12-26 02:50:45.606: E/AndroidRuntime(1776):     at java.lang.reflect.Method.invokeNative(Native Method)
12-26 02:50:45.606: E/AndroidRuntime(1776):     at java.lang.reflect.Method.invoke(Method.java:511)
12-26 02:50:45.606: E/AndroidRuntime(1776):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
12-26 02:50:45.606: E/AndroidRuntime(1776):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
12-26 02:50:45.606: E/AndroidRuntime(1776):     at dalvik.system.NativeStart.main(Native Method)
12-26 02:50:45.606: E/AndroidRuntime(1776): Caused by: java.lang.NullPointerException
12-26 02:50:45.606: E/AndroidRuntime(1776):     at com.example.bmicaldg.MainActivity.onCreate(MainActivity.java:25)
12-26 02:50:45.606: E/AndroidRuntime(1776):     at android.app.Activity.performCreate(Activity.java:5104)
12-26 02:50:45.606: E/AndroidRuntime(1776):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
12-26 02:50:45.606: E/AndroidRuntime(1776):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
12-26 02:50:45.606: E/AndroidRuntime(1776):     ... 11 more

This is the debug logcat:

 12-26 03:04:06.238: I/Process(1854): Sending signal. PID: 1854 SIG: 9
    12-26 03:04:12.779: W/Trace(1876): Unexpected value from nativeGetEnabledTags: 0
    12-26 03:04:12.837: W/Trace(1876): Unexpected value from nativeGetEnabledTags: 0
    12-26 03:04:14.866: D/dalvikvm(1876): GC_CONCURRENT freed 76K, 7% free 2723K/2916K, paused 32ms+32ms, total 270ms
    12-26 03:04:15.427: D/AndroidRuntime(1876): Shutting down VM
    12-26 03:04:15.456: W/dalvikvm(1876): threadid=1: thread exiting with uncaught exception (group=0x40a70930)
    12-26 03:04:15.546: E/AndroidRuntime(1876): FATAL EXCEPTION: main
    12-26 03:04:15.546: E/AndroidRuntime(1876): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.bmicaldg/com.example.bmicaldg.MainActivity}: java.lang.NullPointerException
    12-26 03:04:15.546: E/AndroidRuntime(1876):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
    12-26 03:04:15.546: E/AndroidRuntime(1876):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
    12-26 03:04:15.546: E/AndroidRuntime(1876):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
    12-26 03:04:15.546: E/AndroidRuntime(1876):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
    12-26 03:04:15.546: E/AndroidRuntime(1876):     at android.os.Handler.dispatchMessage(Handler.java:99)
    12-26 03:04:15.546: E/AndroidRuntime(1876):     at android.os.Looper.loop(Looper.java:137)
    12-26 03:04:15.546: E/AndroidRuntime(1876):     at android.app.ActivityThread.main(ActivityThread.java:5039)
    12-26 03:04:15.546: E/AndroidRuntime(1876):     at java.lang.reflect.Method.invokeNative(Native Method)
    12-26 03:04:15.546: E/AndroidRuntime(1876):     at java.lang.reflect.Method.invoke(Method.java:511)
    12-26 03:04:15.546: E/AndroidRuntime(1876):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
    12-26 03:04:15.546: E/AndroidRuntime(1876):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
    12-26 03:04:15.546: E/AndroidRuntime(1876):     at dalvik.system.NativeStart.main(Native Method)
    12-26 03:04:15.546: E/AndroidRuntime(1876): Caused by: java.lang.NullPointerException
    12-26 03:04:15.546: E/AndroidRuntime(1876):     at com.example.bmicaldg.MainActivity.onCreate(MainActivity.java:25)
    12-26 03:04:15.546: E/AndroidRuntime(1876):     at android.app.Activity.performCreate(Activity.java:5104)
    12-26 03:04:15.546: E/AndroidRuntime(1876):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
    12-26 03:04:15.546: E/AndroidRuntime(1876):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
    12-26 03:04:15.546: E/AndroidRuntime(1876):     ... 11 more
    12-26 03:04:22.547: I/Process(1876): Sending signal. PID: 1876 SIG: 9

Any help is appreciated

  • 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-16T07:57:26+00:00Added an answer on June 16, 2026 at 7:57 am

    Change your MainActivity onCreate code as:

    public class MainActivity extends Activity
    
    {
    
        @Override
        public void onCreate(Bundle savedInstanceState)
        {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            View title = getWindow().findViewById(android.R.id.title);
    
            if (title != null) { 
                 ViewParent titleBar = title.getParent(); 
               if (titleBar != null && (titleBar instanceof View)) { 
                    View parentView = (View)titleBar; 
                    parentView.setBackgroundColor(Color.RED); 
                  } 
             } 
    
            // Your Code here...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I am writing an app for my school newspaper, which is run completely online
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I am trying to find ID3V2 tags from MP3 file using jid3lib in Java.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into
I would like to run a str_replace or preg_replace which looks for certain words

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.