*
The moose likes Android and the fly likes Cannot find the problem in the code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Mobile » Android
Bookmark "Cannot find the problem in the code" Watch "Cannot find the problem in the code" New topic
Author

Cannot find the problem in the code

Himanshu S. Soni
Greenhorn

Joined: Jun 11, 2010
Posts: 25

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.


OCPJP 86%
zoheb hassan
Ranch Hand

Joined: Apr 01, 2009
Posts: 146

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

Joined: Jun 11, 2010
Posts: 25



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

Joined: Apr 01, 2009
Posts: 146

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

Joined: Jun 11, 2010
Posts: 25

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

Joined: Apr 01, 2009
Posts: 146

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

Joined: Jun 11, 2010
Posts: 25

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

Joined: Apr 01, 2009
Posts: 146

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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cannot find the problem in the code
 
Similar Threads
EditText force closing with getText().toString()
Httppost Problem
How to retrieve string from EditText?
SharedPreference not working
public void onClick(View v) { // error