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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:34:38+00:00 2026-05-27T05:34:38+00:00

This is the error i get. You can see all the codes that are

  • 0

This is the error i get. You can see all the codes that are affected by this session below. Where i put the intent, where i get it, the classes and paremeters involved.

    11-30 20:37:32.870: E/AndroidRuntime(809): FATAL EXCEPTION: main
    11-30 20:37:32.870: E/AndroidRuntime(809): java.lang.RuntimeException: Unable to start activity ComponentInfo{kfc.project/kfc.project.productdetail}: java.lang.NullPointerException
    11-30 20:37:32.870: E/AndroidRuntime(809):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
    11-30 20:37:32.870: E/AndroidRuntime(809):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
    11-30 20:37:32.870: E/AndroidRuntime(809):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
    11-30 20:37:32.870: E/AndroidRuntime(809):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
    11-30 20:37:32.870: E/AndroidRuntime(809):  at android.os.Handler.dispatchMessage(Handler.java:99)
    11-30 20:37:32.870: E/AndroidRuntime(809):  at android.os.Looper.loop(Looper.java:123)
    11-30 20:37:32.870: E/AndroidRuntime(809):  at android.app.ActivityThread.main(ActivityThread.java:3683)
    11-30 20:37:32.870: E/AndroidRuntime(809):  at java.lang.reflect.Method.invokeNative(Native Method)
    11-30 20:37:32.870: E/AndroidRuntime(809):  at java.lang.reflect.Method.invoke(Method.java:507)
    11-30 20:37:32.870: E/AndroidRuntime(809):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
    11-30 20:37:32.870: E/AndroidRuntime(809):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
    11-30 20:37:32.870: E/AndroidRuntime(809):  at dalvik.system.NativeStart.main(Native Method)
    11-30 20:37:32.870: E/AndroidRuntime(809): Caused by: java.lang.NullPointerException
    11-30 20:37:32.870: E/AndroidRuntime(809):  at kfc.project.productdetail.onCreate(productdetail.java:19)
    11-30 20:37:32.870: E/AndroidRuntime(809):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    11-30 20:37:32.870: E/AndroidRuntime(809):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
    11-30 20:37:32.870: E/AndroidRuntime(809):  ... 11 more

This is the code of the java file


    package kfc.project;

    import android.app.Activity;
    import android.content.Intent;
    import android.os.Bundle;
    import android.widget.EditText;
    import android.widget.TextView;

    public class productdetail extends Activity{

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

            Bundle extras = getIntent().getExtras();

            String name = extras.getString("name");

            if (name != null) {
                TextView text1 = (TextView) findViewById(R.id.servingsize);
                text1.setText(name);
            }
            /*
            Intent intent = getIntent();
            String str = intent.getStringExtra("name");*/

        }





    }

This is the code for the xml file wherein the error goes comes in when i go to this page. It isnt about cleaning the project and the manifest as well cause it works when i delete the settext code 


    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout
      android:scrollbarAlwaysDrawVerticalTrack="true"
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical"
      android:layout_width="match_parent"
      android:layout_height="wrap_content" android:gravity="top|center"
      android:background="@drawable/bg">

        <TableLayout
            android:id="@+id/tableLayout1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" 
            >

            <TableRow
                android:id="@+id/tableRow1"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >


            </TableRow>

            <TableRow
                android:id="@+id/tableRow2"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" android:gravity="right">

                <Button
                    android:id="@+id/button1"      
                    android:background="@drawable/button2"
                    android:textColor="#FFFFFF"   
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:text="ADD TO MENU" android:gravity="right" android:paddingRight="4sp" android:paddingTop="10sp"/>



        <TableRow
            android:id="@+id/tableRow3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" android:gravity="left">

        </TableRow>

        <TableLayout
            android:id="@+id/tableLayout2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >

            <TableRow
                android:id="@+id/tableRow5"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

            </TableRow>

            <TableRow
                android:id="@+id/tableRow6"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

                <TextView
                    android:id="@+id/textView4"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:gravity="left"
                    android:text="Amount Per Serving: "
                    android:textAppearance="?android:attr/textAppearanceMedium" />

                <TextView
                    android:id="@+id/textView7"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="20"
                    android:textAppearance="?android:attr/textAppearanceMedium" />

            </TableRow>

            <TableRow
                android:id="@+id/tableRow7"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

                <TextView
                    android:id="@+id/textView5"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Calories:"
                    android:textAppearance="?android:attr/textAppearanceMedium" />

                <TextView
                    android:id="@+id/textView17"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="30"
                    android:textAppearance="?android:attr/textAppearanceMedium" />

            </TableRow>

            <ImageView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:src="@android:drawable/divider_horizontal_dark"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:scaleType="fitXY"
        android:paddingLeft="5dp"
        android:paddingRight="5dp"
        android:paddingBottom="2dp"
        android:paddingTop="2dp" />

            <TableRow
                android:id="@+id/tableRow8"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

                <TableRow
                    android:id="@+id/tableRow14"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content" >

                    <TextView
                        android:id="@+id/textView3"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:gravity="right"
                        android:text="% Daily Value:          "
                        android:textAppearance="?android:attr/textAppearanceMedium" />

                    <TextView
                        android:id="@+id/textView21"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:text="35"
                        android:textAppearance="?android:attr/textAppearanceMedium" />
                </TableRow>
            </TableRow>

        </TableLayout>

        <TableLayout
            android:id="@+id/tableLayout3"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >

            <TableRow
                android:id="@+id/tableRow9"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

                <TextView
                    android:id="@+id/textView8"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Total Fat:"
                    android:textAppearance="?android:attr/textAppearanceMedium" />

                <TextView
                    android:id="@+id/textView22"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="60"
                    android:textAppearance="?android:attr/textAppearanceMedium" />

            </TableRow>

            <TableRow
                android:id="@+id/tableRow10"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

                <TextView
                    android:id="@+id/textView9"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="       Saturated Fat:"
                    android:textAppearance="?android:attr/textAppearanceMedium" />

                <TextView
                    android:id="@+id/textView23"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="34"
                    android:textAppearance="?android:attr/textAppearanceMedium" />

            </TableRow>

            <TableRow
                android:id="@+id/tableRow11"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

                <TextView
                    android:id="@+id/textView10"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="       Trans Fat:"
                    android:textAppearance="?android:attr/textAppearanceMedium" />

                <TextView
                    android:id="@+id/textView24"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="53"
                    android:textAppearance="?android:attr/textAppearanceMedium" />

            </TableRow>

            <TableRow
                android:id="@+id/tableRow12"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

                <TextView
                    android:id="@+id/textView11"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Cholesterol:"
                    android:textAppearance="?android:attr/textAppearanceMedium" />

                <TextView
                    android:id="@+id/textView25"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="25"
                    android:textAppearance="?android:attr/textAppearanceMedium" />

            </TableRow>

            <TableRow
                android:id="@+id/tableRow13"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

                <TextView
                    android:id="@+id/textView12"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Sodium:"
                    android:textAppearance="?android:attr/textAppearanceMedium" />

                <TextView
                    android:id="@+id/textView26"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="10"
                    android:textAppearance="?android:attr/textAppearanceMedium" />

            </TableRow>

            <TableRow
                android:id="@+id/tableRow15"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

                <TextView
                    android:id="@+id/textView13"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Total Carbohydrate:"
                    android:textAppearance="?android:attr/textAppearanceMedium" />

                <TextView
                    android:id="@+id/textView27"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="200"
                    android:textAppearance="?android:attr/textAppearanceMedium" />

            </TableRow>

            <TableRow
                android:id="@+id/tableRow16"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

                <TextView
                    android:id="@+id/textView14"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="       Dietary Fiber:"
                    android:textAppearance="?android:attr/textAppearanceMedium" />

                <TextView
                    android:id="@+id/textView28"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="34"
                    android:textAppearance="?android:attr/textAppearanceMedium" />

            </TableRow>

            <TableRow
                android:id="@+id/tableRow17"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

                <TextView
                    android:id="@+id/textView15"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="       Sugars:"
                    android:textAppearance="?android:attr/textAppearanceMedium" />

                <TextView
                    android:id="@+id/textView29"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="16"
                    android:textAppearance="?android:attr/textAppearanceMedium" />

            </TableRow>

            <TableRow
                android:id="@+id/tableRow18"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

                <TextView
                    android:id="@+id/textView16"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Protein:"
                    android:textAppearance="?android:attr/textAppearanceMedium" />

                <TextView
                    android:id="@+id/textView30"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="40"
                    android:textAppearance="?android:attr/textAppearanceMedium" />

            </TableRow>
    <ImageView
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:src="@android:drawable/divider_horizontal_dark"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:scaleType="fitXY"
        android:paddingLeft="5dp"
        android:paddingRight="5dp"
        android:paddingBottom="2dp"
        android:paddingTop="2dp" />
    <TableRow
        android:id="@+id/tableRow24"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content" >
    </TableRow>

            <TableRow
                android:id="@+id/tableRow19"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

            </TableRow>

        </TableLayout>

        <TableLayout
            android:id="@+id/tableLayout4"
            android:layout_width="match_parent"
            android:layout_height="wrap_content" >

            <TableRow
                android:id="@+id/tableRow20"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

            </TableRow>

            <TableRow
                android:id="@+id/tableRow21"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

            </TableRow>

            <TableRow
                android:id="@+id/tableRow22"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

                <TextView
                    android:id="@+id/textView19"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Vitamin A: "
                    android:textAppearance="?android:attr/textAppearanceMedium" />
                            <TextView
                    android:id="@+id/textView31"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="40"
                    android:textAppearance="?android:attr/textAppearanceMedium" />

                <TextView
                    android:id="@+id/textView20"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="   Vitamin C: "
                    android:textAppearance="?android:attr/textAppearanceMedium" />
                            <TextView
                    android:id="@+id/textView32"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="30"
                    android:textAppearance="?android:attr/textAppearanceMedium" />

            </TableRow>

            <TableRow
                android:id="@+id/tableRow23"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

                <TextView
                    android:id="@+id/textView6"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="Calcium: "
                    android:textAppearance="?android:attr/textAppearanceMedium" />
                            <TextView
                    android:id="@+id/textView33"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="35"
                    android:textAppearance="?android:attr/textAppearanceMedium" />

                <TextView
                    android:id="@+id/textView18"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="   Iron: "
                    android:textAppearance="?android:attr/textAppearanceMedium" />
                            <TextView
                    android:id="@+id/textView34"
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:text="40"
                    android:textAppearance="?android:attr/textAppearanceMedium" />

            </TableRow>

            <TableRow
                android:id="@+id/tableRow25"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content" >

            </TableRow>

        </TableLayout>

    </LinearLayout>

This is where i put the extras

    package kfc.project;

import java.util.ArrayList;

import android.app.Activity;
import android.app.ListActivity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.Toast;

public class ProductListView extends ListActivity {

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {       
        super.onCreate(savedInstanceState);

        final ProductList pl = new ProductList();

        //setListAdapter(new ArrayAdapter<String>(this, R.layout.list_item, PRODUCTS));
        setListAdapter(new ArrayAdapter<Product>(this, R.layout.list_item, pl.getList() ));

        ListView lv = getListView();
        lv.setTextFilterEnabled(true);

        lv.setOnItemClickListener(new OnItemClickListener() {

          public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

            // When clicked, show a toast with the TextView text
            Toast.makeText(getApplicationContext(), "View Product", Toast.LENGTH_SHORT).show();

            Product product = pl.getList().get(position);

            Intent intent = new Intent(ProductListView.this, productdetail.class);
            intent.putExtra("name",product.getName());
            intent.putExtra("calories", product.getCalories());
            intent.putExtra("serving size", product.getServingSize());
            intent.putExtra("fat", product.getFat());
            intent.putExtra("saturated fat", product.getSaturatedFat());
            intent.putExtra("trans fat", product.getTransFat());
            intent.putExtra("cholesterol", product.getCholesterol());
            intent.putExtra("sodium", product.getSodium());
            intent.putExtra("carbs", product.getCarbs());
            intent.putExtra("protein", product.getProtein());

            ProductListView.this.startActivity(intent);

            startActivity(new Intent("kfc.project.PRODUCTDETAIL"));
          }

        });

    }



    //TEST STRING ARRAY
    static String[] PRODUCTS = new String[] {
        "Chicken", "Rice", "Coke", "Chicken Burger"
    };



}

This is where the array list items are added

    package kfc.project;

import java.util.ArrayList;

public class ProductList {
    ArrayList<Product> list;


    public ProductList (){
        list = new ArrayList<Product>();

        //CREATE PRODUCT HERE
        Product chicken;
        list.add(new Product("ChickenTest",99));    

        Product rice;
        list.add(new Product("RiceTest",11));
    }

    public String[] getNames (){
        int c = 0;
        int size = list.size() - 1;
        String[] names = new String[size];

        while (size >= c) {
            //names.add(list.get(c).getName());
            names[c] = list.get(c).getName();
            c++;
        }

        c = 0;

        return names;
    }

    public ArrayList<Product> getList (){
        return list;
    }

}

This is the code for the parameteres

    package kfc.project;

public class Product {


    String name;
    int servingSize;
    int calories;
    int fat;
    int saturatedFat;
    int transFat;
    int cholesterol;
    int sodium;
    int carbs;
    int protein;


    public Product (String name, int servingSize, int calories, int fat, int saturatedFat, int transFat, int cholesterol, int sodium, int carbs, int protein){
        this.name=name;
        this.calories=calories;
        this.servingSize=servingSize;
        this.fat=fat;
        this.saturatedFat=saturatedFat;
        this.transFat=transFat;
        this.cholesterol=cholesterol;
        this.sodium=sodium;
        this.carbs=carbs;
        this.protein=protein;
    }

    public Product (String name, int servingSize){
        this.name=name;
        this.servingSize=servingSize;
    }

    public String getName() {
        return name;
    }

    public int getServingSize() {
        return servingSize;
    }

    public int getCalories() {
        return calories;
    }

    public int getFat() {
        return fat;
    }

    public int getSaturatedFat() {
        return saturatedFat;
    }

    public int getTransFat() {
        return transFat;
    }

    public int getCholesterol() {
        return cholesterol;
    }

    public int getSodium() {
        return sodium;
    }

    public int getCarbs() {
        return carbs;
    }

    public int getProtein() {
        return protein;
    }


}
  • 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-27T05:34:39+00:00Added an answer on May 27, 2026 at 5:34 am

    the extras variable is NULL

    Bundle extras = getIntent().getExtras();
    String name = extras.getString("name");
    

    Update:

    First, this line is not needed

    startActivity(new Intent("kfc.project.PRODUCTDETAIL"));
    

    Second, you need to getExtra() from getIntent() in productdetail, not getExtras().
    For sample:

    // get intent object once
    Intent receivedIntent = getIntent();
    
    // get product name
    String productName = receivedIntent.getExtra("name"); 
    
    // get serving size
    int servingSize = receivedIntent.getExtra("serving size");
    
    // do the same for other props
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I get this error: Can't locate Foo.pm in @INC Is there an easier way
We get this error in Visual Studio 2005 and TFS very often. Can anyone
I can't seem to compile ironruby in ruby 1.8.7. I always get this error:
I can not get to make this comparison in this simple code error ..
How can I get this to compile? The error is when I start using
Why I get this error? Page not found (404) Using the URLconf defined in
I always get this error when trying to compile my file with Boost::GIL PNG
I get this error on an update panel within a popupControlExtender which is within
I get this error when I do an svn update : Working copy XXXXXXXX
I continue to get this error: Object '%s' cannot be renamed because the object

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.