OnActivityResult()不会被调用 [英] OnActivityResult() is never called

查看:136
本文介绍了OnActivityResult()不会被调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是怎么开始的标签活动

This is how I start the Tab Activity

  Intent i = new Intent("walk.me.TAB");
        startActivityForResult(i, STATIC_RESULT);

注:STATIC_RESULT = -1或RESULT_OK;

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();   
}

和这里是我的OnActivityResult实现:

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"));
                  }
                 }}

为什么onActivityResult永远不会把它称为直接进入OnResume()不管文件garantees的OAR会前或者叫什么名字?我做错了什么?我没有在清单XML声明

Why the onActivityResult is never called it goes directly 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

singleInstance

singleTask

singleTask

为主要业务...

推荐答案

您说STATIC_RESULT是-1?

You say STATIC_RESULT is -1?

请求code必须是一个正整数。

The requestCode has to be a positive integer.

<一个href="http://developer.android.com/reference/android/app/Activity.html#startActivityForResult%28android.content.Intent,%20int%29">startActivityForResult()

参数

意图的意图开始。

要求$ C $)c。如果> = 0,code将在onActivityResult(返回时,活动退出。

requestCode If >= 0, this code will be returned in onActivityResult() when the activity exits.

这篇关于OnActivityResult()不会被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆