onActivityResult不叫Android中不叫、onActivityResult、Android

由网友(年少掌心的梦话@)分享简介:当我我的应用程序启动我显示启动画面。该网页被显示10秒,在一个线程上运行。当切换到新的活动上的结果我想用打一个网址,服务器,我会得到一个返回值,我可以用我的进一步的工具。When i my app is launched i am showing a splash screen. that page is been...

当我我的应用程序启动我显示启动画面。该网页被显示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();
阅读全文

相关推荐

最新文章