Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cannot find the problem in the code

 
Himanshu S. Soni
Greenhorn
Posts: 26
Eclipse IDE Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using Eclipse ADT to learn developing android application.

This simple piece of code given below is used to accept username and password from user, and display it on the next page after hitting Go button.


The code has no errors as far as i know.
However, when i run this code , i get the error


The application login(process academic.login) has stopped unexpectedly.
Please try again.


One more thing which i found out, is that when i comment out from the code from line 1 to line 2. The UI boots up perfectly.
The same problem happened when i was building a calculator, which too is incomplete as a resukt of this problem.
Others sample applications run perfectly, so i am not able to pin point the errors.
 
zoheb hassan
Ranch Hand
Posts: 154
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please Post your complete Code, this code however looks fine with the exception that you have not specified a intent to navigate to next screen also check your Manifest if you have mentioned your second activity there
 
Himanshu S. Soni
Greenhorn
Posts: 26
Eclipse IDE Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


This is my manifest file.
i have to screens Test -> Post. The above code resembles the Test.java activity.



Are there any other places, i should check for errors ?
 
zoheb hassan
Ranch Hand
Posts: 154
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Just use a .Post in android:name attribute and in onClick method

public void onClick(View v) {
Uname = name.getText().toString();
Upass = pass.getText().toString();
new Intent(getBaseContext(), Post.class);
startActivity(i);
}
});

this should work without any errors.Let us know the result
 
Himanshu S. Soni
Greenhorn
Posts: 26
Eclipse IDE Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I made the changes as per your guidance. But no luck.
The application stops unexpectedly.

i will send you the project.
Tell me how to.
Please let me know what error is causing this problem.
As a result of this error, my entire practical work is halted.
I made a calculator, but the same problem persists in it too.
 
zoheb hassan
Ranch Hand
Posts: 154
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Place the code in launchpost method in onclick method and try, it should work if not then post your code here like the way you did earlier and we will solve it

-Zoheb
 
Himanshu S. Soni
Greenhorn
Posts: 26
Eclipse IDE Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No success.
as i said, when i comment out the implementation of onCreate(), the UI boots fine.

Test.java ------ screen 1



Post.java ------ Screen 2

 
zoheb hassan
Ranch Hand
Posts: 154
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Error is at Line number 27,28 of Test Activity where you are trying to set the values of the text View, Trying to use a Static text String would work for java Classes for an Activity however it wont.However you can pass the values from one activity to another via Bundle and retrieve it in another activity using Key Value Pairs



However the exact reason why static String wont work here is something i am not aware of.Lets hope someone answers this in the forum

Best Regards,
-Zoheb
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic