Android: Capturing the return of an activity

问:

I have a question regarding launching new activities. It boils down to this. I have 3 tabs on a view A) contains gMap activity B) camera activity C) some random text fields.

Requirement is that the application runs in Portrait mode.

All 3 tabs work as expected w/ the exception of the Camera Preview Surface (B). It is rotated 90 degrees. They only way to make it correct is to set the app to landscape which throws all my tabs around, and is pretty much unworkable.

My solution is this : replace

my camera activity with a regular activity that is empty w/ the exception of

Intent i = new Intent(this,CameraActivity.class);
    startActivity(i);

This launches my CameraActivity. And that works fine. I had to do a linear layout and include 3 images that look like real tabs, so I can try and mimic the operation of the tabs while rotating the screen to landscape and keep the visuals as portrait. The user can click one of the images(buttons) to display the next tab. This is my issue. It should exit my 'camera activity' returning to the 'blank activity' in a tab, where it should be interpreted to click the desiered tab from my image.

The main thing is, when it returns, it returns to a blank (black) page under a tab (because it is 'empty'). How can I capture the return event back to the page that called the activity, and then see what action they performed?

I can set an onclicklistener where I can respond to the fake tabs (images) being clicked to exit out of the camera activity. On exit, the tab should update so that is where you return. any Suggestions?

Thanks,


答:

I'll focus on answering how to resolve your workround so that it behaves as you want.

To capture actions performed on one Activity within another requires three steps.

Launch the secondary Activity (your 'camera Activity') as a subactivity by usingstartActivityForResult instead of startActivity.

Intent i = new Intent(this,CameraActivity.class);    
startActivityForResult(i, STATIC_INTEGER_VALUE);

Within the subactivity (camera Activity), rather than just closing the Activity when a user clicks the different tab image, you need to create a new Intent and include the index of the tab to display when you return to the parent app using the extras bundle. To pass it back to the parent call setResult before calling finish to close the camera Activity.

resultIntent = new Intent(null);
resultIntent.putExtra(PUBLIC_STATIC_STRING_IDENTIFIER, tabIndexValue);
setResult(Activity.RESULT_OK, resultIntent);
finish();

The final step is in the calling Activity, override onActivityResult to listen for callbacks from the camera Activity. Get the extra from the returned Intent to determine the index of the tab you should be displaying.

@Override 
public void onActivityResult(int requestCode, int resultCode, Intent data) {     
  super.onActivityResult(requestCode, resultCode, data); 
  switch(requestCode) { 
    case (STATIC_INTEGER_VALUE) : { 
      if (resultCode == Activity.RESULT_OK) { 
      int tabIndex = data.getIntExtra(PUBLIC_STATIC_STRING_IDENTIFIER);
      // TODO Switch tabs using the index.
      } 
      break; 
    } 
  } 
}

"divide and grow: capturing huge diversity in crowd images with incrementally" 是一个标题,该标题是基于一种方法或者技术,用于在人群图像中捕捉巨大的多样性。该方法通过逐步分割和增长的方式来实现。 在传统的人群图像处理中,通常会面临到一个挑战,即人群中的个体数量巨大且多样性丰富。这使得对整个人群图像进行全局处理变得困难。 "divide and grow"方法通过将人群图像分割成更小的区域,并在每个区域中逐步增加分析的粒度来解决这个问题。 首先,该方法会将人群图像划分成多个重叠的子区域。然后,对每个子区域进行单独的分析,以捕捉到区域内的个体。这种分割使得处理的任务更加可管理,同时也可以提高对于人群中不同个体的检测能力。接下来,"divide and grow"方法会逐步增加分析的粒度,即进一步细分每个子区域,以更准确地捕捉到更多的个体。 通过这种逐步分割和增长的方式,"divide and grow"方法可以较好地捕捉到人群图像中的巨大多样性。这种方法可以帮助在人群中准确地检测和识别各种不同类型的个体,例如不同年龄、性别、服装等。 总之,"divide and grow: capturing huge diversity in crowd images with incrementally"是一种用于处理人群图像中巨大多样性的方法。通过逐步分割和增长的方式,该方法可以有效地捕捉到人群中各种不同类型的个体。这种方法可以在人群图像处理和识别中具有广泛的应用潜力。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值