Android open activity from fragment showing two screen separately - android

I have created an app. which contains MainActivity->inside fragments class loading with some UI works..
After I have tried to pass some datas to new Library Activity (inside one fragment available with make some works and need to get back result.)
Problem: when i open new activity, its showing two separate apps like..
starting Activity Page and Library Activity.. But, after entered library activity, finish the work and get back result to MainActivity Successfully..
Note: Even, Library Activity showing as a seperate App. thats my problem.
Please help..Thanks for Advance

Related

How can i switch main activity not in manifest?

I making android app. I have 3 activites:
first(main) activity which is empty and it's like navigation which ask you to add item.
Second activity which is needed for adding item's details and this activity have accept button which leads you to third activity.
Third activity have all data about item and from now on i want my app to make this activity main (default) activity with saving information about it in device memory.
I decided to make it without database because it should be really simple.
Can you help me with making 3rd acitivity main? Maybe there are some tricks.
not clear what you trying to ask. Like if user reached the 3rd activity, in the future if user open the app the app will automatically navigate them to the 3rd activity?
If that's the case, you could save this information in the shared preference, when the app start, the first activity check this value and navigate to the 3rd activity.
Recommend you use a single activity, use fragments for different pages, and use Navigation component to connect them. https://developer.android.com/guide/navigation/navigation-getting-started

App appears in task switcher more than once

I am developing my first app now and I see that whenever I click on a new activity it opens up and everything is fine. I can also go back to the main activity and then open a different and it all works.
However once I open the task switcher, all the previous activities show up. They all show up as seperate apps and if I click on one of them that is not the main activity I cannot go back the to the main activity its like its very own up with just that activity.
This is very strange. Does this have to do with how I implement the onDestory method? Because to be quite frank I never used it.
Please help me!
Thank you!

How can we know that in an activity which fragment is loaded currently when we come in foreground from background?

I have an activity named captureActivity ,which do qr code scanning.when scanning done a fragment opens and display contents of scanning.I have an issue that this activity always opens in background, i open any fragment after scanning.Scanning always open in background.I just want that ones scanning done ,camera should be release until i open that activity again.
You can find current fragment loaded in container by using this:
getFragmentManager().findFragmentById(R.id.contanerID)
If you are using app fragment or if you are using v4 fragment then use this:
getSupportFragmentManager().findFragmentById(R.id.containerID);

Android barcodescanner still image with multiple ZXingScannerView

in my app I have a fragment using the dm77/barcodescanner.
I'm working on a shop app, ex: you scan an item -> page of product -> continue shopping -> open another scanner sessione -> etc.
Now, as you can see, because the clinet wants to maintain the back stack, multiple istances of that fragment could be open (but not at the same time).
The first fragment with the scanner works well, the others has a still image, even if I call
scannerView.stopCamera();
scannerView = null;
leaving the first fragment.
NOTE: the other fragment works well if, instead of add we use replace. But that will create problems on the fragment's animations.
After furious debugging, I found how to make all working:
When the fragment is visible / in use, create and add programmatically to your layout the ZXingScannerView, starting the camera and preview;
When the fragment is not visible / used, remove the ZXingScannerView from your layout;
On some android version (like 5.01) be careful to not call startCamera more than one time, otherwise you'll not be able to open it anymore until you restart the app. The error here is caused by dead thread exception.
Hope to have been enough clear and helpful.

Android Multi-Screen Application

How do you handle multiple screens in an android application? I have developed with the tab bar at the bottom without problem, however what I am wanting to do is replace all the content on the screen with the content from a new .xml layout file I have created in the project. Additionally, how would I tie the back end code to the new layout file? I'm sure this question probably exists already and is googleable (may have made up a new word). However, I don't know exactly what it is that I am looking for. Thanks in advance for your help.
What you need to do is, create a new Activity and add it to the AndroidManifest.xml:
<activity android:name="ActivityClassName" android:label="Label for the Activity"></activity>
and can be called in a method:
public void startActivity() {
Intent someName = new Intent(CurrentClass.this, ActivityClassName.class);
startActivity(someName);
}
Android applications generally use a separate Activity for each screen, and switch between them using Activity.startActivity and Activity.startActivityForResult. You can pass arbitrary data to an Activity via Intent.putExtra.
Hope this helps,
Phil Lello
It really depends on how you want your application to flow.
Let's consider the scenario where a user does the following:
Starts your first activity
Presses the 2nd tab
Presses the 3rd tab
Presses the back button
If you use a separate activity for each screen, then the following would happen
Activity 1 is started
Activity 2 is started
Activity 3 is started
Activity 3 is closed, user returns to Activity 2
(in this case pressing the back button again would you take you back to Activity 1, and pressing it again would exit your application)
If you used one activity for all the tabs, then the following would occur
Activity 1 is started
Activity 1 sets tab content to tab 2 content
Activity 1 sets tab content to tab 3 content
Activity 1 is closed, user returns to home screen
If you are using a screen with tabs, then the second method (a single Activity with a TabHost or similar) is the preferred method, otherwise the user will end up making a large activity-stack just switching between tabs (meaning if they switch between tabs a lot they'll have to press the back button a lot of times to exit).
If you want to go for the single activity approach, then do some research on TabHost and TabContentFactory. In the createTabContent method of your factory you can inflate a View/layout from XML to set as the tab content using View.inflate. Look those up and come back ask another question if you get stuck ;)
i think you may want to play with more than one activity.... you can have multiple activities and one xml for each of them... in this way you can have different screens... check these links. Multiple Activities, Creating an Activity.... hope this helps...

Categories

Resources