• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to check equality of strings ?

 
chetan dhumane
Ranch Hand
Posts: 641
Android Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I am getting exception on phone activity named "i" can't start.

Thanks
 
Sagar Rohankar
Ranch Hand
Posts: 2904
1
Java Spring Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What's 'i' and 'j' ?
 
Imran Mohd
Ranch Hand
Posts: 38
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey how can we help you if your not providing the complete code...
 
chetan dhumane
Ranch Hand
Posts: 641
Android Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Here is complete code
All intents are properly initialized int Manifest file .
 
Rohan Dhruva
Ranch Hand
Posts: 183
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Strings in android are normal Java strings - your use of .equals() is quite appropriate, the problem must lie somewhere else.
 
Sagar Rohankar
Ranch Hand
Posts: 2904
1
Java Spring Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


A silly doubt, Is this class (Notepadv3.class) visible ?
 
Rohan Dhruva
Ranch Hand
Posts: 183
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also, every new activity you create must be added to the android manifest.xml..
 
chetan dhumane
Ranch Hand
Posts: 641
Android Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Notpadv3 is visible.

All classes are registered into the Manifest file.

I can run Notepadv3 manually.
 
Monu Tripathi
Rancher
Posts: 1369
1
Android Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you post a dump of your exception? That way people wont be shooting in dark..

Thanks.
 
chetan dhumane
Ranch Hand
Posts: 641
Android Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

View complete dump , which I get using adb

Line number 10 is the exception
 
Imran Mohd
Ranch Hand
Posts: 38
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey you are Calling showDialog(DIALOG_TEXT_ENTRY); from onCreate() method which display the Dialog immediately
when the Activity get started ,Than how can enter any thing in to the EditText ..

And one more thing mUserText.getText() will return Editable object not the String object

so try using mUserText.getText().toString()

 
Ed Burnette
Author
Ranch Hand
Posts: 142
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There are two problems in the code:

1. The two text fields don't exist in the original activity so they're being set to null. You need to find them in the view that you inflated, like this:

2. getText() is returning an Editable object. Usually you can use Editable wherever you use a String because they both implement CharSequence, but not in this case. Sorry I forgot to mention this earlier. The fix is to call toString() in the middle like this:
 
chetan dhumane
Ranch Hand
Posts: 641
Android Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks alot.
Once again javranch rocks.
 
chetan dhumane
Ranch Hand
Posts: 641
Android Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

No i checked all the things it recognizes the click but it does not start a new activity.
I tried using Toast in the click event it goes upto that event but when i check for the equality it fails.
 
chetan dhumane
Ranch Hand
Posts: 641
Android Eclipse IDE Java
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Imran ,

I have to use EditText while reading from textbox ,Am i right ?
 
Ed Burnette
Author
Ranch Hand
Posts: 142
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I made the changes above in my copy and it worked fine. Of course there's some bad recursion going on (an activity launching itself) but I assume that's just temporary code for demonstration.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic