I have developed a recipe search application that obtains data from an API and it allows the user to view and save the data.
My android application uses multiple fragments within one activity. They share one container and when a new fragment is loaded it replaces the old fragment.
My application has the following fragments: Home, Search, Filters, RecipeView and more.
I am experiencing multiple issues with popping the fragment back stack once a search has been carried out or a favourite recipe has been displayed. The search fragment is a grid view that uses a custom adapter, and to perform a search the user uses a toolbar search view which executes code upon pressing the submit (return) button.
The home fragment is displayed first allowing a user to click a quick search button such as breakfast, clicking the button displays the search fragment with results from the API. The user can then click on an item which opens the RecipeView fragment, pressing the back button on these fragments does not cause an issue and a user can navigate back to the previous fragments including the home one that was displayed initially.
Additionally, a user can navigate to the search fragment using the navigation drawer. The search fragment allows the user to perform a search or click a filter via buttons on the toolbar. Clicking the search icon/button allows a user to enter text and once they press enter/return the search is perform and the grid view is populated.
Prior to performing a search or clicking the search button, pressing the filter button displays the filters fragment and from there, pressing the back button will allow a user to navigate back to the search view fragment.
If the user presses the search button which will open the search view menu item (allowing text input on the toolbar) and then presses the filters button, the filters activity is displayed. However, pressing the back button does not navigate to the previous fragment, it removes the focus from the toolbar. Pressing the back button again still does not navigate back and changes the toolbars text back to the search fragments specified title ("Recipe Search"). Pressing the back button again will then navigate back to the search fragment, removing the filters fragment from sight.
I have tried removing the focus from the toolbar so that pressing back is not removing toolbars focus and the app still requires three back button presses.
Furthermore, I am having another issue with fragments overlaying each other. From the home fragment that is loaded on create, if a user navigates using the side menu to the favourites fragment, a list of the saved favourites in a grid view are shown using the search fragment. Pressing the back button from the search fragment does not cause any issues and the app will navigate back to the home fragment; additionally, clicking a recipe will open the RecipeView fragment displaying a recipes information.
The issue arises from here. If the back button is pressed the app will navigate backwards loading the home fragment not the search fragment and the recipe fragment stays on screen causing both fragments to overlap. Pressing the back button again will remove the home fragment and leave the recipe fragment in the container; pressing the back button again will close the application (The search fragment is not shown and the order is incorrect).
1. I have tried implementing this ([Avoid fragments overlapping])
2. I have tried calling classes using a new instance method rather than creating new ones in the MainActivity
3. I have tried to add fragments rather than replace them
4. I have tried overriding the back button press
5. I have tried addToBackStack(null) & addToBackStack(FragmentTag)
6. I have tried to remove all views from the frame layout within my fragment handler method
I have created android application to stream online radio stations but when I click start button to play radio it won't start.In service I read ip address of file from url and add it to string.When user selects radio station I add port to string with ip address.
I created android application to stream online radio stations but it doesn't work.I want to read ip address from url and assign it to string and when user selects radio to listen I should add port to that string!!!
Depending on how long it takes your thread code to finish parsing http://audiophileradio.stream/Ip.txt, your preferences/append code is also accessing the text variable. What's the possibility of that happening out of order?
Have you tried hard-coding the value passed to setDataSource() to see if the reset of your player-related code is correct?
This is unrelated to the problem you are having, but the four if() tests are not as efficient as they could be. You are checking radio's value four more times than is necessary. Consider:
How to Develop Shopping cart in Android,With PHP MYSQL Database Connectivity,and After that it will redirect to the payment module.
As i am doing Payment with Instamojo the Payment app is ready as well as static Shopping Cart is ready...But How to Connect with Database...
Kindly Help Me,I am Working On this Project Since last two weeks but nothing is fruitful.
I need some advice to properly implement MVVM with what I'm trying to do.
1) I have a WebView control in a View because I need user to manually login to a website.
2) Once login, it will set a flag to indicate that user has logged in. It will then go to another link in the website and periodically read a html element value.
3) The values read will then be displayed in a table in another View.
4) In the scenario when the user is logged off from the website, it will show the website login page again. And then it will continue to Step 2 and Step 3.
5) The View that has the WebView control only need to be shown for the user to log in to the website. After logging in, the View can be hidden, and only showing the table which contains the values read, which are periodically updated.
I have few ideas on how to implement it but I am not sure if my idea is correct or not.
Have 2 View/ViewModel pair. 1 View/ViewModel (VM1) to display out the readings read. Another View/ViewModel (VM2) which contains WebView control for the user to login. VM1 will periodically trigger VM2 (by using mediator pattern) to read from the website. As VW2 tries to read from the website, if the user is not logged in to the website, it will go to the log in page. Once the user has logged in, it will go to the webpage that contains the html element and read the value. It will stay in that webpage so that the next time VW1 triggers VM2 to read the value, it can readily do so without user intervention.
Eventhough user may close the VM2's View, the View is not really closed. It is just hidden and the program is still able to read from the webpage in the background.
Have View/ViewModel (VM1) to display out the value in the table. VM1 calls a service that does the reading of webpage. The service has a WebView control. If the user is not logged in, the service will instantiate a View/ViewModel (VM2) and passing in the WebView control which the user can use to log in. Once the user has logged in, the WebView control is passed back to the service so that the service can continue to read the html element. The service then triggers the ViewModel (VM2) to close the View.
Please advice on what is the correct MVVM way to do what I'm trying to do.
Hi Richard.. forgive me for the misunderstanding..
Sifus is referring to Teacher/Master in Chinese because I'm still learning and there are a lot of very experienced people in this forum.
Actually, it is Sifu.. I just use Sifus to make it plural..
I have created android application with navigation drawer and when I click item from navigation drawer old fragment is not replaced,I can still see the old fragment under the new fragment.How to fix this issue?
privatevoid displaySelectedScreen(int id)
Fragment fragment = null;
fragment = new Main();
Intent intent = new Intent(this, Settings.class);
Intent intent1 = new Intent(this, About.class);
Intent i = new Intent(Intent.ACTION_SEND);
String sAux = "\nLet me recommend you this application\n\n";
sAux = sAux + "https://play.google.com/store/apps/details?id=Orion.Soft \n\n";
startActivity(Intent.createChooser(i, "choose one"));
fragment = new Feedback();
if (fragment != null)
FragmentManager fragmentManager = getSupportFragmentManager();
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
@Overridepublicboolean onNavigationItemSelected(MenuItem item)
// Handle navigation view item clicks here.int id = item.getItemId();
Hello everyone i need to hashed my password when i put it in my login application android and then i need to compare it with my password in my table fos_user of symfony and the password in fos_user is encoders:bcrypt
This is my code:
// Check whether username or password is set from android
if(isset($_POST['username']) && isset($_POST['password']))
// Innitialize Variable
$username = $_POST['username'];
$password = $_POST['password'];
$hash = password_hash($password, PASSWORD_BCRYPT);
// Query database for row exist or not
$sql = "SELECT password FROM fos_user WHERE username = '$username' AND password = '$hash'";
$test = mysql_query($sql) or die( mysql_error() );
$row = mysql_fetch_assoc($test);
if ($hash == $row['password'])
// send result back to android