为什么 OnActivityResult() 从未被调用?
这就是我启动选项卡活动
Intent i = new Intent("walk.me.TAB");
startActivityForResult(i, STATIC_RESULT);
注意的方式:STATIC_RESULT=-1
或 RESULT_OK;
。
这就是我完成 Tab 活动的方式
((Button)viewItem.findViewById(R.id.gotherefav)).setOnTouchListener(new OnTouchListener(){
@Override
public boolean onTouch(View v, MotionEvent event) {
if(ime!=null)
{
b.putString("ime",ime.toString());
b.putIntArray("koordinati&kategorija", coordAndCat );
b.putBoolean("klik", true);
FinishWithResult(b);
}
return false;
}});
public void FinishWithResult(Bundle b)
{
Intent i = getIntent();
i.putExtras(b);
setResult(Activity.RESULT_OK, i);
Log.i("in FINISH", "settig Activity Result");
finish();
}
这是我的 OnActivityResult
实现:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.i("in OnActivityResult", "Activity Result");
Toast.makeText(getBaseContext(), "DOJDE", Toast.LENGTH_LONG).show();
super.onActivityResult(requestCode, resultCode, data);
Log.i("in OnActivityResult", "Activity Result");
if (requestCode == STATIC_RESULT) {
if (resultCode == RESULT_OK) {
Toast.makeText(getBaseContext(), "DOJDE BUNDLE", Toast.LENGTH_LONG).show();
Bundle preferenciOdTab = data.getExtras();
if(preferenciOdTab !=null && preferenciOdTab.getBoolean("klik", true))
{
mapView = (MapView)findViewById(R.id.map);
isFavorite=preferenciOdTab.getBoolean("klik");
drawFavorite(preferenciOdTab.getString("ime"),preferenciOdTab.getIntArray("koordinati&kategorija"));
}
}}
为什么 onActivityResult
从未被调用,而是直接转到 OnResume()
文档保证 OAR 将在 OR 之前被调用?我做错了什么?我没有在清单xml中声明
单实例
或
单任务
主要活动的
This is how I start the Tab Activity
Intent i = new Intent("walk.me.TAB");
startActivityForResult(i, STATIC_RESULT);
Note: STATIC_RESULT=-1
or RESULT_OK;
.
This is how I finish the Tab activity
((Button)viewItem.findViewById(R.id.gotherefav)).setOnTouchListener(new OnTouchListener(){
@Override
public boolean onTouch(View v, MotionEvent event) {
if(ime!=null)
{
b.putString("ime",ime.toString());
b.putIntArray("koordinati&kategorija", coordAndCat );
b.putBoolean("klik", true);
FinishWithResult(b);
}
return false;
}});
public void FinishWithResult(Bundle b)
{
Intent i = getIntent();
i.putExtras(b);
setResult(Activity.RESULT_OK, i);
Log.i("in FINISH", "settig Activity Result");
finish();
}
And here is my OnActivityResult
implementation:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
Log.i("in OnActivityResult", "Activity Result");
Toast.makeText(getBaseContext(), "DOJDE", Toast.LENGTH_LONG).show();
super.onActivityResult(requestCode, resultCode, data);
Log.i("in OnActivityResult", "Activity Result");
if (requestCode == STATIC_RESULT) {
if (resultCode == RESULT_OK) {
Toast.makeText(getBaseContext(), "DOJDE BUNDLE", Toast.LENGTH_LONG).show();
Bundle preferenciOdTab = data.getExtras();
if(preferenciOdTab !=null && preferenciOdTab.getBoolean("klik", true))
{
mapView = (MapView)findViewById(R.id.map);
isFavorite=preferenciOdTab.getBoolean("klik");
drawFavorite(preferenciOdTab.getString("ime"),preferenciOdTab.getIntArray("koordinati&kategorija"));
}
}}
Why is onActivityResult
never called and directly goes to OnResume()
regardless of the documentation garantees that OAR will be called before OR? What I'm doing wrong? I dont have stated in manifest xml
singleInstance
or
singleTask
for the Main activity.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你说STATIC_RESULT是-1?
requestCode 必须是正整数。
startActivityForResult()
参数
You say STATIC_RESULT is -1?
The requestCode has to be a positive integer.
startActivityForResult()
Parameters