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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:10:22+00:00 2026-05-27T08:10:22+00:00

i want to pass data between two activities.In the first activity i m using

  • 0

i want to pass data between two activities.In the first activity i m using this code:

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


             Intent newActivity = new Intent(museum.this, museum_item.class);
           newActivity.putExtra("TXT_RESOURCE",R.string.infomuseum1);
            newActivity.putExtra("IMG_RESOURCE",R.drawable.infohistory);

            startActivity(newActivity);
             break;

and in the second i m using

 public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.museum); 


Bundle extras = getIntent().getExtras();
String textResourceId = extras.getString("TXT_RESOURCE");
int imgResourceId = extras.getInt("IMG_RESOURCE");

TextView museum_item_text = (TextView) findViewById(R.id.museum_item_text);
museum_item_text.setText(textResourceId);


  ImageView museum_item_image = (ImageView) findViewById(R.id.museum_item_image); 
  museum_item_image.setImageResource(imgResourceId);

but i m getting error and my app forces down..Where is my wrong?This is the logcat

12-08 19:35:04.905: E/AndroidRuntime(7689): Uncaught handler: thread main exiting due to uncaught exception
12-08 19:35:04.905: E/AndroidRuntime(7689): java.lang.RuntimeException: Unable to start activity ComponentInfo{kostas.menu.heraklion/kostas.menu.heraklion.museum_item}: java.lang.NullPointerException
12-08 19:35:04.905: E/AndroidRuntime(7689):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2268)
12-08 19:35:04.905: E/AndroidRuntime(7689):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2284)
12-08 19:35:04.905: E/AndroidRuntime(7689):     at android.app.ActivityThread.access$1800(ActivityThread.java:112)
12-08 19:35:04.905: E/AndroidRuntime(7689):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1692)
12-08 19:35:04.905: E/AndroidRuntime(7689):     at android.os.Handler.dispatchMessage(Handler.java:99)
12-08 19:35:04.905: E/AndroidRuntime(7689):     at android.os.Looper.loop(Looper.java:123)
12-08 19:35:04.905: E/AndroidRuntime(7689):     at android.app.ActivityThread.main(ActivityThread.java:3948)
12-08 19:35:04.905: E/AndroidRuntime(7689):     at java.lang.reflect.Method.invokeNative(Native Method)
12-08 19:35:04.905: E/AndroidRuntime(7689):     at java.lang.reflect.Method.invoke(Method.java:521)
12-08 19:35:04.905: E/AndroidRuntime(7689):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:782)
12-08 19:35:04.905: E/AndroidRuntime(7689):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
12-08 19:35:04.905: E/AndroidRuntime(7689):     at dalvik.system.NativeStart.main(Native Method)
12-08 19:35:04.905: E/AndroidRuntime(7689): Caused by: java.lang.NullPointerException
12-08 19:35:04.905: E/AndroidRuntime(7689):     at kostas.menu.heraklion.museum_item.onCreate(museum_item.java:24)
12-08 19:35:04.905: E/AndroidRuntime(7689):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1123)
12-08 19:35:04.905: E/AndroidRuntime(7689):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2231)
12-08 19:35:04.905: E/AndroidRuntime(7689):     ... 11 more

museum_item.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
 <ImageView
        android:id="@+id/museum_item_image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
      />
    <TextView
        android:id="@+id/museum_item_text"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
         />



</LinearLayout>
  • 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-27T08:10:23+00:00Added an answer on May 27, 2026 at 8:10 am

    It would help if you pointed out which line of your code (line 24, according to the logcat) is causing the problem. My guess is that you aren’t finding one of the views museum_item_text or museum_item_image, the corresponding view variable is being set to null by the call to findViewById, and then you’re getting a NPE on the next line.

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

Sidebar

Related Questions

I am trying to pass data between two pages using Session State in ASP.NET.
I want to pass data between a Python and a C# application in Windows
I want to create light object data-package to pass between client and server applications.
I have two pages and I want to pass data to each other. How
i have two flex applications and i want to pass the data from one
I want to do something like this: c:\data\> python myscript.py *.csv and pass all
I have one application in which I want to pass data between Pages (Views)
I have two activities in which I need to pass an object array between
for my application I need to pass data between my activity and the the
...for use in a multithreaded network server. I want to pass data around between

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.