Results 1 to 11 of 11
  1. #1
    Lion is offline Member
    Join Date
    Sep 2013
    Posts
    12
    Rep Power
    0

    Default App crash, issue with links I am guessing!

    Hi guys again, I want to say I am really sorry for posting so many questions!

    I am having a massive issue with the app crashing I think it is to do with the links to many or just the wrong way. When clicking on the first link on the first page going to the next page with a lot more links onn it, it crashes. Here is the code! I would love for some help!


    Java Code:
    package com.example.space;
    
    import android.os.Bundle;
    import android.app.Activity;
    import android.view.View;
    import android.widget.Button;
    
    public class MainActivity extends Activity {
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            
            Button main = (Button) findViewById(R.id.main);
            main.setOnClickListener(new View.OnClickListener() {
    			
    			@Override
    			public void onClick(View v) {
    				setContentView(R.layout.list);
    				
    				Button sol = (Button) findViewById(R.id.sol);
    				sol.setOnClickListener(new View.OnClickListener() {
    					
    					@Override
    					public void onClick(View v) {
    						setContentView(R.layout.solar);
    						
    							
    					}
    					
    				}); //End of Solar
    				
    				Button milk = (Button) findViewById(R.id.milk);
    				milk.setOnClickListener(new View.OnClickListener() {
    					
    					@Override
    					public void onClick(View v) {
    						setContentView(R.layout.milk);
    						
    					}
    					
    				}); //END OF MILK
    				
    				
    				Button neb = (Button) findViewById(R.id.neb);
    				neb.setOnClickListener(new View.OnClickListener() {
    					
    					@Override
    					public void onClick(View v) {
    						setContentView(R.layout.neb);
    						
    					}
    					
    				}); //END OF NEB
    				
    				Button sun = (Button) findViewById(R.id.sun);
    				sun.setOnClickListener(new View.OnClickListener() {
    					
    					@Override
    					public void onClick(View v) {
    						setContentView(R.layout.sun);
    						
    					}
    				}); //END OF SUN
    				
    				
    				
    				
    			}
    			
    		}); //End
            
            
            
            
        }
    }
    Again I am sorry for so many questions!

    I am just making this app to practice with!

  2. #2
    Lion is offline Member
    Join Date
    Sep 2013
    Posts
    12
    Rep Power
    0

    Default Re: App crash, issue with links I am guessing!

    Anyone Know?

  3. #3
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default Re: App crash, issue with links I am guessing!

    The answer is probably in the stack trace. If you don't know what that is, read this: logcat | Android Developers. If you can't find the crash amid all the debug spam, search the log for "FATAL".
    Get in the habit of using standard Java naming conventions!

  4. #4
    Lion is offline Member
    Join Date
    Sep 2013
    Posts
    12
    Rep Power
    0

    Default Re: App crash, issue with links I am guessing!

    OK thank you I will have a look at the link!

  5. #5
    Lion is offline Member
    Join Date
    Sep 2013
    Posts
    12
    Rep Power
    0

    Default Re: App crash, issue with links I am guessing!

    So I found out that it was the Images that is causing the crash, how can images cause the crash? They are just normal .jpg images. Does it need .gif or .png to to work?

  6. #6
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,098
    Rep Power
    6

    Default Re: App crash, issue with links I am guessing!

    Weird image setup, bug in Android API code that it doesn't handle images with specific properties (such as a compression scheme) properly, image uncompressed being so large it doesn't fit into memory... three reasons why it could fail. There are probably more. Only experimentation will tell what is the truth. Try another JPEG for example, preferably generated by another program. See if the problem persists.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  7. #7
    Lion is offline Member
    Join Date
    Sep 2013
    Posts
    12
    Rep Power
    0

    Default Re: App crash, issue with links I am guessing!

    OK I took a look at the image at it was huge! Over 4k px. So I put it down to 100px X 92px and it worked no crash.

    I have a few more images to fix and it should be OK.

    So thank you so much for your help!

  8. #8
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Location
    Netherlands
    Posts
    4,098
    Rep Power
    6

    Default Re: App crash, issue with links I am guessing!

    Weird, 4k pixels is not huge at all though. But if you're helped, I'm not going to argue.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

  9. #9
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,091
    Rep Power
    20

    Default Re: App crash, issue with links I am guessing!

    Of course we don't know what the actual crash was.
    That is, what the exception was.
    As gimbal says, 4k is not a lot of pixels, unless you actually mean 4k on a side.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  10. #10
    Lion is offline Member
    Join Date
    Sep 2013
    Posts
    12
    Rep Power
    0

    Default Re: App crash, issue with links I am guessing!

    I had no idea about px size really (With Java and android) I guess it could of been anything.

    BUT I have one more issue that stands in front of me and a finished app.

    A back button.

    Java Code:
    Button bntBack= (Button) findViewById(R.id.bntBack);
    one.setOnClickListener(new View.OnClickListener() {
    
    @Override
    public void onClick(View arg0) {
    setContentView(R.layout.list);
    }
    This does not work as I need it too, it goes back to another page BUT none of the java code for that page works, how is this fixed?

    Thanks for the help guys!

  11. #11
    kjkrum's Avatar
    kjkrum is offline Senior Member
    Join Date
    Apr 2011
    Location
    Tucson, AZ
    Posts
    1,060
    Rep Power
    6

    Default Re: App crash, issue with links I am guessing!

    If you want to go back in the activity stack, call finish(). If you want to add a new activity to the stack, use startActivity(...) or startActivityForResult(...). You can't use setContentView(...) to change activities. It displays the UI widgets defined in the XML for a given activity; it doesn't change activities. So that explains why it appears you've changed activities, but nothing works. An activity should only call setContentView(...) to set up its own UI, not another activity's.
    Last edited by kjkrum; 10-02-2013 at 07:27 AM.
    Get in the habit of using standard Java naming conventions!

Similar Threads

  1. Replies: 5
    Last Post: 09-25-2013, 06:13 AM
  2. Replies: 1
    Last Post: 08-24-2013, 06:22 PM
  3. Number Guessing Game issue
    By gabrielpr12 in forum New To Java
    Replies: 14
    Last Post: 01-24-2012, 11:06 PM
  4. Guessing with Numbers
    By Quinix in forum Java Gaming
    Replies: 1
    Last Post: 10-27-2010, 08:01 PM
  5. Guessing Game
    By rose in forum Java Gaming
    Replies: 4
    Last Post: 10-27-2010, 08:00 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •