I am newbie android programmer. just started by seeing some online tutorials, i decided to make a application for myself.. it was working fine till yesterday.. The only change i made today was to add this line "this.requestWindowFeature(Window.FEATURE_NO_TITLE);" and it stated throwing the error. pls provide the solution for this.
public class MainActivity extends Activity implements OnClickListener, Runnable {
Context context;
EditText editTextNum, editText, editUserName, editPassword;
Button btnsend;
ProgressDialog pd;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
editUserName = (EditText) findViewById(R.id.edit_userName);
editPassword = (EditText) findViewById(R.id.edit_password);
editTextNum = (EditText) findViewById(R.id.edit_number);
editText = (EditText) findViewById(R.id.edit_message);
btnsend = (Button) findViewById(R.id.btnsend);
btnsend.setOnClickListener(this);
}
/** Called when the user clicks the Send button */
public void sendMessage() {
if (!isOnline()) {
Toast.makeText(MainActivity.this,"No Internet Access..Cannot Send SMS", Toast.LENGTH_LONG).show();
} else {
String userName = editUserName.getText().toString();
String password = editPassword.getText().toString();
String number = editTextNum.getText().toString();
String message = editText.getText().toString();
String msgreciever = number;
String testMessage = message;
try {
SmsSender.sendMessage(msgreciever, testMessage, userName, password);
} catch (Exception ex) {
Toast.makeText(MainActivity.this, "SMS Sending Failed.",Toast.LENGTH_LONG).show();
}
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;
}
public boolean isOnline() {
ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkInfo netInfo = cm.getActiveNetworkInfo();
if (netInfo != null && netInfo.isConnectedOrConnecting()) {
return true;
}
return false;
}
public void onClick(View v) {
// TODO Auto-generated method stub
if (v == btnsend) {
if (!isOnline()) {
Toast.makeText(MainActivity.this,"No Internet Access..Cannot Send SMS",Toast.LENGTH_LONG).show();
} else {
pd = ProgressDialog.show(MainActivity.this, "Free Sms","Sending SMS..Please Wait..!!", true);
Thread t = new Thread(this);
t.start();
}
}
}
public void run() {
// TODO Auto-generated method stub
sendMessage();
mHandler.sendEmptyMessage(0);
}
public Handler mHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
// TODO Auto-generated method stub
super.handleMessage(msg);
pd.dismiss();
Toast.makeText(MainActivity.this, "Message Sent Successfully",Toast.LENGTH_LONG).show();
editTextNum.setText("");
editText.setText("");
editTextNum.requestFocus();
}
};
}