我检查了toast message和key.retrieveapi的条件是否为0,但活动未启动,我在日志中也没有看到任何错误。这是我的密码:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ApiKeyDao key=new ApiKeyDao(this);
setContentView(R.layout.activity_main);
//Toast.makeText(this, "user"+key.retrieveApi().status, Toast.LENGTH_SHORT).show();
if(key.retrieveApi()==null) {
setContentView(R.layout.activity_main);
}
else if(key.retrieveApi().getStatus()==1) //1== Existing user
{
Intent profile=new Intent(this,HomeFeed.class);
startActivity(profile);
}
else if(key.retrieveApi().getStatus()==0) // 0= new user
{
Toast.makeText(this, "working", Toast.LENGTH_SHORT).show();
Intent profile=new Intent(MainActivity.this,ProfileActivity.class);
profile.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(profile);
}
else
{
setContentView(R.layout.activity_main);
}
任何帮助都将不胜感激。
1条答案
按热度按时间cgh8pdjw1#
你试过了吗?意图概要文件=新意图(此,profileactivity.class);