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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T20:13:33+00:00 2026-06-06T20:13:33+00:00

Stack Trace Picture of stack trace here Values aren’t being passed to the other

  • 0

Stack Trace

Picture of stack trace here

Values aren’t being passed to the other intent. Every time I try to start the activity with the intent in it, it crashes.

//This activity will retrieve and display the different rewards that are available.
public class RewardsActivity extends Activity {


@Override
public void onCreate(Bundle SavedInstanceState)
{
    super.onCreate(SavedInstanceState);
    setContentView(R.layout.rewards);
    
    //stores retrieves and stores the current gridview
    GridView gridView = (GridView)findViewById(R.id.grid_view);
    
    //Instance of ImageAdapter class that will load the images into the gridview
    gridView.setAdapter(new ImageAdapter(this));
    
    //This function is used to set a listener on each item in the grid so that      when its clicked it will go to the other view.
    gridView.setOnItemClickListener(new OnItemClickListener(){
        public void onItemClick(AdapterView<?> parent, View v,int position, long id)
        {
            Intent i = new   Intent(getApplicationContext(),RewardsViewActivity.class);
            i.putExtra("id", position);
            startActivity(i);
        }
        
    });
    
    

}

This new intent is being passed to, when it’s passed here it is stored in a variable then used in a ImageView to load an image.

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

public class RewardsViewActivity extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.full_view);

    // get intent data
    Intent i = getIntent();

    // Selected image id
    int position = i.getExtras().getInt("id");
    ImageAdapter imageAdapter = new ImageAdapter(this);

    ImageView imageView = (ImageView) findViewById(R.id.full_image);
    imageView.setImageResource(imageAdapter.finalImages[position]);
}

}

ImageAdapter.java
package org.android.pps;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.ImageView;

/*This class will be used handle the loading of the image view that will display all the
images of the rewards. (this will be used along with RewardsActivity and rewards.xml)
 */
public class ImageAdapter extends BaseAdapter {

    //variable that will store the current context of the application
    private Context c;
    private Integer num = 6;
    private int[] rewards_num=new int[num];
    private Integer[] Images = new Integer[6];
    public Integer[] finalImages;
    
    
    
    //for loop will set the correct image to the array if its either activated or deactivated
    
    public Integer[] fillImageArray()
    {
        //Array that will be used to show the reward images
        
        Integer[] Activated ={
            R.drawable.rewards1,
            R.drawable.rewards2,
            R.drawable.rewards3,
            R.drawable.rewards4,
            R.drawable.rewards5,
            R.drawable.rewards6,
        };
        Integer[] Deactivated ={
                R.drawable.rewards1b,
                R.drawable.rewards2b,
                R.drawable.rewards3b,
                R.drawable.rewards4b,
                R.drawable.rewards5b,
                R.drawable.rewards6b,
            };
        
        
        //for loop that checks to see all the rewards that a particular users has to assign a particular image.
        for(int x = 0;x<rewards_num.length;x++)
        {
        
            for(int y = 0;y<6;y++)
            {
                if(rewards_num[x]==y)
                {
                    Images[x]=Activated[y];
                    
                }
                else
                {
                    Images[x]=Deactivated[y];
                }
            }
            }
        
        return Images;
        
    
    }
    
    
    //constructor with the context being passed.
    public ImageAdapter(Context m)
    {
        c = m;
        
    }

    public int getCount() {
        
        return 6;
    }

    public Object getItem(int position) {
        
        return Images[position];
    }

    public long getItemId(int position) {
        return 0;
    }

    
    // The function View  create a new ImageView for each item that is being referenced by the Adapter
    public View getView(int position, View convertView, ViewGroup parent) {
        finalImages = fillImageArray();
        ImageView imageView = new ImageView(c);
        imageView.setImageResource(finalImages[position]);
        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
        imageView.setLayoutParams(new GridView.LayoutParams(300, 300));
        return imageView;
  
    }
    
    
    
}  
  • 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-06T20:13:35+00:00Added an answer on June 6, 2026 at 8:13 pm

    finalImages in noi initialized there ………

    it is finalImages in the getview which is not get called in 2nd activity (RewardsViewActivity )………..

    if possible move this line to constructor finalImages = fillImageArray();

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

Sidebar

Related Questions

Here is the stack trace which appears on resque-web interface: http://gist.github.com/396893 There you can
Here's my error, in picture format in case it's easier to read: https://i.stack.imgur.com/iuE8f.png I
I have here a stack trace from one of my games from android market.
here is my stack trace [NullReferenceException: Object reference not set to an instance of
Here is the stack trace: Traceback (most recent call last): File V:\Users\Administrator\AppData\Roaming\Blender Foundation\Blender\2.61\scripts\addons\ArenWorldExporter.py, line
I have the following stack trace from valgrind. But it does not give me
I want to retrieve stack trace from a user dump file programmatically . There
I have the following stack trace. Is it possible to make out anything useful
How do I get the current stack trace in Java, like how in .NET
I want to disable the stack trace getting generated when an exception is thrown.

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.