Android: activity return capture

I have a question regarding the launch of new activities. It comes down to that. I have 3 tabs in a view

A) contains gMap activity B) camera activity C) some random text fields. 

The requirement is that the application runs in portrait mode.

All 3 tabs work as expected, except for the camera preview surface (B). It rotates 90 degrees. This is the only way to get it right - to set the app to a landscape that throws all my tabs, and is largely inoperative.

My solution is this: replace

my camera activity with regular activity that is empty except

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

This launches my CameraActivity. And it works great. I had to make a linear layout and include 3 images that look like real tabs, so I can try to simulate the work of the tabs by rotating the screen to the landscape and saving the visual effects as a portrait. The user can click one of the images (buttons) to display the next tab. It is my problem. It should exit my “camera activity”, returning to the “empty activity” on the tab where it should be interpreted in order to click the “Desired” tab from my image.

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

I can install onclicklistener where I can respond to fake tabs (images) that need to be clicked to exit the camera action. When exiting, the tab should be updated so that it returns. any suggestions?

Thank,

+80
android android-intent android-activity exit
Jan 16 '09 at 4:05
source share
2 answers

I will focus on the answer on how to allow your desktop to behave the way you want.

To capture actions performed for one action in another, three steps are required.

Launch secondary activity (your "camera activity") as subactivity, using startActivityForResult instead of startActivity .

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

As part of subactivity (camera activity), instead of just closing the action when the user clicks on another tab image, you need to create a new Intent and enable the index of the tab displayed when you return to the parent application using the add-on package. To pass it to the parent call to setResult before calling finish to close the camera action.

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

The final step in the calling activity is to override onActivityResult to listen for callbacks from the camera action. Get more information from the return intent to determine the index of the tab that you should display.

 @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; } } } 
+157
Jan 16 '09 at 8:20
source share
 private boolean firstTime = true; @Override protected void onResume() { super.onResume(); Toast.makeText(this, "First time here? "+ firstTime , Toast.LENGTH_LONG).show(); firstTime = false; } 
0
Jan 17 '19 at 22:32
source share



All Articles