Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/session.php on line 1007: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781

Strict Standards: Non-static method utf_normalizer::nfc() should not be called statically in /www/htdocs/w006661d/anddev/includes/utf/utf_tools.php on line 1781
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4362: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4364: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4365: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 4366: Cannot modify header information - headers already sent by (output started at /includes/utf/utf_tools.php:1781)
anddev.org • View topic - Application Crashes with an If...Else Statement

Application Crashes with an If...Else Statement

Put your problem here if it does not fit any of the other categories.

Application Crashes with an If...Else Statement

Postby travisjames » Thu Apr 09, 2009 7:51 am

I have this code:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. import android.widget.Toast;
  2.  
  3. import android.content.SharedPreferences;
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
  11. public class TwitterIt extends Activity {
  12.  
  13.     /** Called when the activity is first created. */
  14.  
  15.     @Override
  16.  
  17.     public void onCreate(Bundle savedInstanceState) {
  18.  
  19.         super.onCreate(savedInstanceState);
  20.  
  21.         setContentView(R.layout.main);
  22.  
  23.        
  24.  
  25.        
  26.  
  27.         Button update = (Button) findViewById(R.id.update);
  28.  
  29.         update.setOnClickListener(new Button.OnClickListener() {
  30.  
  31.                 public void onClick(View v) {
  32.  
  33.                         EditText status = (EditText) findViewById(R.id.status);
  34.  
  35.                         String updtext = status.getText().toString();
  36.  
  37.                        
  38.  
  39.                         SharedPreferences settings = TwitterIt.this.getSharedPreferences
  40.  
  41.                         ("com.travisjames.twitterit_preferences", 0);
  42.  
  43.                         String value = settings.getString("user", "defaultvalue");
  44.  
  45.                         String value2 = settings.getString("pass", "defaultvalue");
  46.  
  47.                        
  48.  
  49.                         if (value == "" || value2 == "") {
  50.  
  51.                                 Toast.makeText(TwitterIt.this, "Please enter your Twitter Username in Settings", Toast.LENGTH_LONG).show();
  52.  
  53.                         }
  54.  
  55.                         else {
  56.  
  57.                         Twitter twitter = new Twitter(value,value2);
  58.  
  59.                         twitter.setSource("twitterit");
  60.  
  61.                         twitter.updateStatus(updtext);
  62.  
  63.                         status.setText("");
  64.  
  65.                 }
  66.  
  67.                 }
  68.  
  69.         });
  70.  
  71.     }
Parsed in 0.012 seconds, using GeSHi 1.0.8.4


For some reason, when I empty the username preference and push my button, the application crashes and does not display the Toast I have created.
travisjames
Junior Developer
Junior Developer
 
Posts: 17
Joined: Thu Apr 02, 2009 10:00 pm
Location: Cordova, Tennessee

Top

Postby young » Thu Apr 09, 2009 8:45 am

add finish() below :Toast.makeText(TwitterIt.this, "Please enter your Twitter Username in Settings", Toast.LENGTH_LONG).show();

try again.
young
Developer
Developer
 
Posts: 26
Joined: Thu Apr 17, 2008 6:27 pm

Postby travisjames » Thu Apr 09, 2009 9:31 am

Thanks for your help.

It worked!
travisjames
Junior Developer
Junior Developer
 
Posts: 17
Joined: Thu Apr 02, 2009 10:00 pm
Location: Cordova, Tennessee

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 13 guests