恢复后启动活动 [英] Start activity after Resume
本文介绍了恢复后启动活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的发车活动是 LoginView
。
如果登录是正确的我叫 startActivity(新意图(LoginView.this,MainView.class));
和完成()
。
所以,我的应用程序切换到的MainView
如果我preSS后退按钮的应用程序转到研究背景。
我的问题:
如果我恢复应用程序(长preSS Home键),我总是回 LoginView
并没有给 MAINVIEW
的MainView:
保护无效的onCreate(捆绑savedInstanceState){
// TODO自动生成方法存根
super.onCreate(savedInstanceState);
的setContentView(R.layout.mainlayout);
}
请帮忙
解决方案
login.setOnClickListener(新View.OnClickListener()
{
公共无效的onClick(查看视图)
{
字符串名称= username.getText()的toString()。
共享preferences设置= preferenceManager.getDefaultShared preferences(getApplicationContext());
共享preferences.Editor编辑= settings.edit();
editor.putString(用户名,名);
如果(name.equals(XXX))
{ 意向意图=新意图(currentactivity.this,nextactivity.class);
intent.putExtras(包);
startActivityForResult(意向,0);
}
}
});
My start activity is a LoginView
.
If the login was correct i call startActivity(new Intent(LoginView.this, MainView.class));
and finish()
.
So my App switch to the MainView
and if i press the back button the app goes to the backgroud.
My Problem:
If i resume the app (long press the home key) i always come back to the LoginView
and not to the Mainview
MainView:
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.mainlayout);
}
Please help
解决方案
login.setOnClickListener(new View.OnClickListener()
{
public void onClick(View view)
{
String name=username.getText().toString();
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
SharedPreferences.Editor editor = settings.edit();
editor.putString("username", name);
if(name.equals("xxx"))
{
Intent intent=new Intent(currentactivity.this,nextactivity.class);
intent.putExtras(bundle);
startActivityForResult(intent,0);
}
}
});
这篇关于恢复后启动活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文