Android SearchView.getQuery() returns null - android

I have a search widget as a collapsible action view. I want to save the user entered query on device rotation. I have tried to use
searchView.getQuery().toString();
on different places in my code.
The problem I am facing is that it is always returning nothing/null. What can be the problem?

Related

webview- window.getselection() value is coming null

I am working on an android application,which has a WebView. in this web view when i select the html text and perform any action the window.getSelection() is coming null.
One javascript method window.getSelection() doesn't return the selected text from WebView every time. Many developers raised issues to Google for this but no solutions. https://issuetracker.google.com/issues/36925404
I tried all possible option to get the selection object like
window.getSelection(); window.doument.getSelection(); document.getSelection(); EReader.Selection.Range.getCurrentRange();
Do you have any suggestions?

Query.equalTo(value) or Query.startAt(value).endAt(value) causes delay in sync

My queries with .equalTo() return out-of-date data when used with addListenerForSingleValueEvent, while removing .equalTo() causes the listener to return updated data. Any idea why?
.
I'm using the following query to fetch user's posts from Realtime Database with persistance enabled on Android:
mDatabase.child("posts").orderByChild("uid").equalTo(id)
where id is the id of the current user and each post stores its author's id as a field.
When .equalTo(id) is present, the new posts for the particular user are not returned in that query for the first few minutes. Even more, it seems to affect other queries for the same root ("posts") that contain .orderByChild. Eg, following would also fail to recognise the new post:
mDatabase.child("posts").orderByChild("archived")
Once I remove the .equalTo(id) the behaviour goes back to normal. I'm using addListenerForSingleValueEvent. Tried it also withaddValueEventListener which fires two events, one without the new post, one with it. Without .equalTo(id) both single and non-single listeners return the new post in the first callback. Restarting the app doesn't seem to help straight away - the first event stays out-of-date for the next few minutes. The new post is successfully fetched by different queries in other parts of the application (eg mDatabase.child("posts").child(id))
Any idea why .equalTo() causes such behaviour and how to avoid it (other than using non-single listener and ignoring first event)?
Note 1: same thing happens for .startAt(id).endAt(id)
Note 2: other parts of the Realtime Database are functioning normally, device is connected to the internet and new posts are containing the valid uid field matching the current user.
Update 26/10/2016
Calling mDatabase.child("posts").startAt(key).limitToFirst(4) also produces similar behaviour when trying to query a segment of the database (in our case to implement infinite scroll). It seems that explicitly adding .orderByKey() fixes that particular problem: mDatabase.child("posts").orderByKey().startAt(key).limitToFirst(4).
Though the issue outlined in the original question remains.
I've ran into the exact same problem as you, and after experimenting with almost everything, I've managed to solve it on my end.
I'm scanning barcodes and fetching foods that have the scanned barcode:
Query query = refFoods.orderByChild("barcode").equalTo(barcode);
query.addListenerForSingleValueEvent(new Value ... })};
On my rules i had
".indexOn": "['barcode']"
and after i changed it and took the "[]" out as in:
".indexOn": "barcode"
it started working delay free, where before it would take something like 5 minutes to udpate.

Problems with Listpicker App Inventor

I'm a beginner at App Inventor and I don't know what I'm doing wrong with the listpicker.
I am trying to create and app to reproduce the music I have stored in my server but when i display the listpicker I can't click any of the options and also I can't go back to the first screen. Here I put my code:
Image 1
Image 2
I tried to remove the line that says call listpicker.open but it only made appear a totally black screen.
The result of the code I just posted is exactly what I spect a list with the name and the link of the 2 songs I already upload to my server but when I click them it didn't do anything.
Thanks for your help.
The Web component works asynchronously, which means, it takes a little bit, until the result is available. The result you will get in the Web.GotText event.
Therefore it does not make sense to call the updateListpicker procedure in the Listpicker.BeforePicking event, because the result still is not available and you get displayed an empty listpicker. The listpicker will be opened, before you have received the result!
Set the listpicker to visible=false and use a button.click event to call the updateListpicker procedure. Then as you already do it in the Web.GotText event, assign the received list to the listpicker and open it.

SimpleDB - how long after insert until item is available to be read?

I have a Fragment, and once the user presses OK, an Item is added to my database and its ID is added to the ArrayAdapter. Immediately after, the adapter tries to draw the view, but the first time it tries to get its attributes, it returns a null HashMap (it gets drawn properly the following times).
Is there a way to make sure the item is in the table before trying to get its attributes?
Even putting the attribute retrieval into a while loop until it returns a not-null HashMap doesn't work so it doesn't look to be an issue of time.
You need to do Select or GetAttributes with ConsistentRead=true as Amazon SimpleDB supports two read consistency options: eventually consistent read and consistent read. Eventually consistent read is default. For more detail please refer doc. link
Try using AsynTask.
Add item to database in doInBackground.
Read it in postExecute.
You are done.

Android : onSearchRequested() capture text

I am developing a sample for searching functionality.
I have used onSearchRequested() and on calling it, I get an edit box in which I can enter
the search parameter.
What I would like to do is, I want to capture the text entered in the edit box as I would like to send it to another activity.
Generally for an editText that is defined by us , we can access it using its 'id'.
But, since in the case of onSearchRequested(), the editText is creted automatically , so how can I access and capture the text typed in it.
Have a look at the documentation regarding creating a search interface. Part of the documentation is an example on how to set up a SearchableActivity that is called with the query entered by the user and that should do the searching and showing the results. I guess this is exactly what you want.

Categories

Resources