问题描述
我是新来的机器人。我有一个验证的用户数,然后一个loginActivity启动searchactivity。
I am new to android. I have a loginActivity which validates a user number and then starts a "searchactivity".
在运行时,我看到了搜索活动即将到来(用户进行验证后),但Android是有停止loginActivity问题。
At runtime, I see the search activity coming up (after user is validated) but then android is having problems stopping the loginActivity.
我收到一个了java.lang.RuntimeException:无法停止活动{com.insruance / com.insurance.LoginActivity}:android.app.SuperNotCalledException:活动
在android.app.ActivityThread.performStopActivityInner(ActivityThread.java:3413)
I am getting a "java.lang.runtimeexception: Unable to stop activity {com.insruance/com.insurance.LoginActivity}: android.app.SuperNotCalledException : Activityat android.app.ActivityThread.performStopActivityInner(ActivityThread.java:3413)"
我真的AP preciate如果有人能指出我在做什么错了。
I would really appreciate if someone could point to what I am doing wrong.
code:
public class LoginActivity extends Activity{
DatabaseWrapper myDbHelper;
private String agentNumber;
private OnClickListener btnClickListner = new OnClickListener()
{
@Override
public void onClick(View v)
{
// TODO Auto-generated method stub
// = new DataBaseHelper();
try {
Log.d("LoginActivity->onClick", "Before findByID");
EditText editText = (EditText)findViewById(R.id.txtUserNumber);
Log.d("LoginActivity->onClick", "After findByID");
agentNumber = editText.getText().toString();
String msg = "";
AgentDbHelper agentHelper = new AgentDbHelper(myDbHelper.getDatabaseHandle());
Log.d("LoginActivity->onClick", "Before agentIDExists");
if (agentHelper.agentIDExists(agentNumber))
msg = "Login success";
else
msg = "Login failed";
Log.d("LoginActivity->onClick", "After agentByID");
myDbHelper.closeDatabase();
myDbHelper = null;
Toast.makeText(getBaseContext(),
"User " + agentNumber + " found!",
Toast.LENGTH_LONG).show();
callSearchActivity();
}
catch(SQLException sqlEx)
{
Log.d("login - onclick", sqlEx.toString());
}
catch (Exception e) {
// TODO: handle exception
Log.d("login - onclick", e.toString());
}
}
};
private void callSearchActivity()
{
Intent intent = new Intent(getBaseContext(), SearchActivity.class);
Bundle bun = new Bundle();
bun.putString("agentNumber", agentNumber);
intent.putExtras(bun);
startActivity(intent);
}
@Override
public void onStop() {
try {
Log.d("In LoginActivity->onStop", "about to close myDbHelper");
if (myDbHelper != null)
{
myDbHelper.closeDatabase();
Log.d("In LoginActivity->onStop", "after myDbHelper is closed");
}
} catch (Exception e) {
// TODO Auto-generated catch block
Log.d("In LoginActivity->onStop exeption", e.toString());
//e.printStackTrace();
}
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
try {
setContentView(R.layout.login);
Button loginButton = (Button)this.findViewById(R.id.btnLogin);
loginButton.setOnClickListener(btnClickListner);
myDbHelper = new DatabaseWrapper(this);
myDbHelper.openDatabase();
}
catch(Exception e) {
Log.e("ERROR", "ERROR IN CODE:"+e.toString());
}
}
}
}}
推荐答案
以上有一点点向我指出这一点。
A little more digging pointed me to this.
我不调用重写的onStop内super.onStop()。
I was not calling super.onStop() within the overriden onStop.
我本来以为的Eclipse将脚本这一行就创造了的onStop我的时候。
I would have thought that Eclipse would have scripted this line when it created the onStop for me.
这篇关于机器人:无法停止活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!