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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:50:53+00:00 2026-05-28T03:50:53+00:00

When i try to run the app on my phone,it force closes when i

  • 0

When i try to run the app on my phone,it force closes when i try to do activity 3.
Logcat says:

01-13 17:53:25.368: E/AndroidRuntime(3235): Caused by: java.lang.NullPointerException
01-13 17:53:25.368: E/AndroidRuntime(3235): at android.app.activity3.onCreate(activity3.java:18)

where line 18 is

Button wg = (Button) findViewById(R.id.Back); 

heres my full code for activity3.java:

package android.app;
import android.app.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;


public class activity3 extends Activity{

    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main3);

        Button wg = (Button) findViewById(R.id.Back);
        wg.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                Intent intent = new Intent();
                setResult(RESULT_OK, intent);
                finish();
            }

        });
    }
}

Thanks in advance

  • 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-28T03:50:53+00:00Added an answer on May 28, 2026 at 3:50 am

    You need to modify your xml:

    <?xml version="1.0" encoding="utf-8"?>
    
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >
    
        <!-- your textview -->
        <TextView
            android:id="@+id/text1"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/text1"
            android:textAppearance="?android:attr/textAppearanceMedium"
            />
    
        <!-- your back button -->
        <Button
            android:id="@+id/back"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/Back"
            />
    
    </RelativeLayout>
    

    What I did:

    • Removed text and orientation from your root RelativeLayout, these do nothing.
    • Modified your height and width, feel free to change these as you please.
    • Added a Button with id of R.id.back and text of @string/Back.

    You will now be able to reference your button using findViewById(R.id.back) and set your click listener.

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

Sidebar

Related Questions

whenever I try to run something in Java, Eclipse changes into the PHP perspective.
I recently try twitter app on Android-based phone ( HTC HD Desire , I
I have an iPhone app that I'm trying to run on my phone via
I can run and debug my Android app on my phone just fine, most
I have a simple Silverlight app that I want to run on Windows Phone
I try to run jsf application in myeclipse using jboss web server and following
I try to run one program in myeclipse where after creating one web project
When I try to run a .NET assembly ( boo.exe ) from a network
Every time I try to run a small application that uses a Derby DB
When I try to run a particular stored procedure on my MS SQL 2005

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.