I made an application that just works great. But when I click on the “cancel” or “normal” button, instead of linking me to result.java, the simulator gives me “The application stopped unexpectedly, try again” Here is the code
import android.app.Activity;
import android.content.ComponentName;
import android.content.Intent;
import android.database.CursorJoiner.Result;
import android.os.Bundle;
import android.view.View;
import android.widget.AutoCompleteTextView;
public class lib_main extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
public void onAddClick (View botton){
AutoCompleteTextView title = (AutoCompleteTextView)findViewById(R.id.Title);
AutoCompleteTextView author = (AutoCompleteTextView)findViewById(R.id.Author);
AutoCompleteTextView isbn = (AutoCompleteTextView)findViewById(R.id.ISBN);
Intent intent = new Intent();
intent.setClass(this,Result.class);
intent.putExtra("Title", title.getText().toString());
intent.putExtra("Author", author.getText().toString());
intent.putExtra("ISBN", isbn.getText().toString());
startActivity(intent);
}
public void onCancelClick(View botton){
Intent intent = new Intent();
intent.setComponent(new ComponentName(this,Result.class));
intent.putExtra("Cancel","Cancel");
startActivity(intent);
}
}
this is the result. java
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
public class Result extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.result);
TextView resultText=(TextView)findViewById(R.id.resultText);
Bundle bundle =getIntent().getExtras();
if(bundle.getString("Cancel")!= null)
{
resultText.setText("operation cancel");
}
else
{
String book =bundle.getString ("Title");
String title =bundle.getString ("Author");
String isbn =bundle.getString ("ISBN");
resultText.setText(getString (R.string.resultOk)+""+book+""+ title+""+isbn);
}
}
}
in the error log is written "There is no command at startup:" am start-n com.Library.doc / com.Library.doc.lib_main-a android.intent.action.MAIN-c android.intent.category.LAUNCHER 'in the device emulator -5554 "
source
share