本文介绍了onActivityResult不叫Android中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我我的应用程序启动我显示启动画面。该网页被显示10秒,在一个线程上运行。当切换到新的活动上的结果我想用打一个网址,服务器,我会得到一个返回值,我可以用我的进一步的工具。

When i my app is launched i am showing a splash screen. that page is been shown for 10 sec, running on a thread. When it switches over to new activity on a result i want o hit an url in server and i will be getting an return value which i can use for my further implements.

以下是我的code

private final int SPLASH_DISPLAY_LENGHT = 1000;

new Handler().postDelayed(new Runnable()
        {
            @Override
            public void run()
            {
                Log.e("Handler ","run");
                Intent myIntent = new Intent(getApplicationContext(), CaptureActivity.class);
                startActivityForResult(myIntent, imgDL);
                finish();
            }
        }, SPLASH_DISPLAY_LENGHT);



public void onActivityResult(int requestCode, int resultCode, final Intent data)
      {
          super.onActivityResult(requestCode, resultCode, data);
          if (requestCode == imgDL)
          {
              Log.e("onActivity Result","");
              urlHitMethod("http://XXXXXXXXXXXXXXXXXX.com/banner_scan");
          }
      }

但这里的onActivty结果不被调用,如何使它得到落实......

But here the onActivty result is not been called, how to make it get implemented....

推荐答案

在CaptureActivity.class你必须设置的结果,然后检查onActivityResult的第一个活动,结果code

In the CaptureActivity.class you have to set the result and then check in the onActivityResult in the First Activity the result code

在CaptureActivity.class应该像下面的

In the CaptureActivity.class it should be like the following

 Intent in = new Intent();
    setResult(1,in);//Here I am Setting the Requestcode 1, you can put according to your requirement
    finish();

这篇关于onActivityResult不叫Android中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-26 16:06
查看更多