问题描述
所以,我真的在这里损失。我有我的主要的onCreate尝试加载一个文件,如果文件不存在,我想调用一个startActivityForResult得到一些意见。我的code完全跳过了startActivityForResult,虽然。我从LogCat中得到什么和code只是继续前进。调用处理程序或东西startActivityForResult工作,但它不会为我的应用程序工作。这里是我的code。
So I'm really at a loss here. I have my main onCreate try and load a file, if the file doesn't exist I want to call a startActivityForResult to get some input. My code completely skips over the startActivityForResult,though. I get nothing from LogCat and code just continues onward. Calling the startActivityForResult in a handler or something works, but it's not going to work for my app. Here's my code.
我主要的onCreate:
My main onCreate:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
findViews();
setListeners();
Stuffs stuffs = DomUtil.getFullDom(this);
if (stuffs != null) {
// do stuff
}
else {
startActivityForResult(new Intent(this, SelectType.class), 0);
addNew(1, null);
}
currentScreen = 1;
}
该为的onCreate选择类型我试图拨打:
The onCreate for SelectType I'm trying to call:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.selecttype);
findView();
setListeners();
}
我在做什么错在这里?我能想到的唯一的事情是调用startActivityForResult中的onCreate,但我已经看到它的完成教程。这是怎么回事呢?
What am I doing wrong here? The only thing I can think is calling startActivityForResult in onCreate, but I've seen tutorials where it's done. What's going on here?
推荐答案
startActivityForResult()是不应该返回结果;它开始指示的活动,并继续上。当其他活动用的结果完成,你的onActivityResult()方法将其结果被调用。活动异步执行。
startActivityForResult() is not supposed to return a result; it starts the indicated activity and continues on. When the other activity finishes with a result, your onActivityResult() method will be called with the result. The activities execute asynchronously.
这篇关于startActivityForResult中的onCreate越来越跳过的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!