I am trying to integrate Chrome Custom Tabs in my Android App. Here is the requirement where I am stuck:
1. List of pdfs being shown in GridView. The user when clicks on any pdf will be opened on custom tabs. Here I will pass the position of item in GridView.
2. This position will be used for selection. There will be a SELECT action on custom tab. When the user clicks on SELECT, the custom tab should close passing the position back to the activity so that I can mark that item in GridView selected.
Now the problem is in closing the Custom Tab and passing the data back to activity. Any help in this regard will be highly appreciated.
There is no such support currently to close chrome custom tab programatically.
But you can close it by starting your previous activity from where you launched chrome custom tab.
For this, set your activity launchMode as "singleTask" and then start your activity with FLAG_ACTIVITY_CLEAR_TOP when ACTION button is clicked.
Then chrome custom tab will be automatically closed and the previous activity will be shown from where chrome custom tab was opened.
You can check details from here: How to close chrome custom tabs .
Related
I Have used inbuilt android navigation drawer and now i want to implement multi fragment navigation like as gmail.
1.first image When click on Google mail, it will redirect to Google details with back button icon in preview fragment(image2).
2.second image when click on back button its open again first image (main activity with default fragment) instated of navigation drawer.
So Same way i want to implement in my app, Please help me how to achieve this scenario?
In default fragment i have placed editfieds and submit button. when click on submit button redirect to new fragment, now click on back button on new fragment i want to come back the default fragment.
I am a beginner in android. I have created Tabs using ActionBar tabs. Now I want to implement, when the user in in first tab and clicks back Button activity should close or when the user is in second tab, he clicks the backbutton the app should show the first tab, which will make it as the home tab. I tried using popupbackstack() but it always closes the activity no matter what tab i am in.
please guide me. Thanks in advance.
The easiest way would be record the tab state (i.e., which tab is showing) in the host activity, and override the onBackPressed() method to do what you want.
Some tips:
remember to save the state(override the onSavedInstanceState() and save the tab state) to make you activity works right after restore from onPause().
read about android's recommended navigation style here. What you designed is a little bit different from what android suggests.
I have implemented the SlidingMenu successfully.
What my requirement is that I have a menu in the form of listview .
Now few of the list items have one more component (e.g. status) which needs to be updated dynamically everytime the user opens the menu.
I'm not able to achieve this.
Please help me .
You have to override the method which is called when the slider is opened. There you have to add the code to update your list data.
Hey can we hide/show tab layout on button click which will be placed below the tab widget it self.
Eg :
When i try to hide - setVisible(View.GONE) the tabwidget whole screens goes black.
The most straightforward way to me would just use the android menu as the way to choose between different tabs instead of a real tab view. When the user clicks on a menu button, you load another activity and the menu gets hidden again.
The tabhost is meant to stay there throughout the entire app lifecycle. Using it like this would be wrong. A way to achieve this using the tab would be to set it completely invisible and then load the activity that normally is in the tab on the whole screen.
I have created a TabActivity in my android application. When user selects the second tab, an alert dialog will appear. Is there any way to navigate to the previous tab when user clicks the cancel button for the dialog box.
regards
dj
I found the solution here:
Android - Switch Tabs from within an Activity within a tab
In my case, I have used the solution of 'GrandPrix'.
I think you need to first know about the Tab Widget:
http://developer.android.com/resources/tutorials/views/hello-tabwidget.html
http://www.androidpeople.com/android-tabhost-tutorial-part-1/
You can set the tab using setCurrentTab method:
tab_host.setCurrentTab(2); // 2nd tab button is showing initially
same way, you can set the tab-button on the cancel button.