In Choreographer.FrameCallback.doFrame event, their a value called frameTimeNanos. what exactly mean this value and more important how to use it, I mean in with scenario we need to take care of this value?
Related
I need to manually override the value that Google analytics sends for the deviceCategory predefined user dimension (let's say that instead of "mobile", I need It to be "android phone"). But I couldn't find anywhere in the SDK documentation if this is possible or not, and how to do it, other than using a custom dimension, which is not what I want.
Is this even possible?
You can definitely override some of the default dimensions as shown here You could probably follow the same algo to override other dimensions.
Another thing I'd try is looking at the network request and seeing if deviceCategory can be overriden by setting it as an event propery.
Finally, you can always override any field if you use GTM inbetween, but it's kind of an overkill. You don't want to use it just to slightly shift the field value.
I would generally suggest either not touching it at all if you're just renaming it for the comfort of the analyst or using a custom dimension/event propery to track it if it's a separate datapoint.
I am making a custom IME. I am trying to track when the user manually changes the selection region of text (as opposed to the selection changing as a result of actions from the IME itself, like commitText).
To do this, I am keeping track of where the IME expects the selection position to be, and compares it to the actual selection position from onUpdateSelection.
For example, to commit text I use:
private fun commitTextToInputConnection(text: String)
{
moveExpectedSelection(text.length)
service.currentInputConnection.commitText(text, 1)
}
However, if I do:
commitTextToInputConnection("Test1")
commitTextToInputConnection("Test2")
I find that, in order, the following sequence occurs:
1 - ExpectedSelectionPosition updates for "Test1"
2 - ExpectedSelectionPosition updates for "Test2"
3 - onUpdateSelection for "Test1" is called
4 - onUpdateSelection for "Test2" is called
Obviously, this order is incorrect, and leads to my IME having an incorrect ExpectedSelectionPosition.
The strangest thing is that, for some Activities, the sequence of ExpectedSelectionPosition updates and onUpdateSelection calls always occur in the correct order. For other Activities, they consistently occur in the same (wrong) order.
What is going on here? I'm guessing commitText, etc, must be asynchronous, leading to this race condition, but this is not mentioned at all in the documentation.
Are there are any work-arounds to this issue? Or, are there any other ways I can listen exclusively for changes in text selection triggered manually by the user, and not the IME?
The solution was to use InputConnection.beginBatchEdit and InputConnection.endBatchEdit.
Any changes made to the currentInputConnection within a 'batchEdit' block are lumped together into a single onUpdateSelection call, at the end.
For example, when the following is executed:
service.currentInputConnection.beginBatchEdit()
commitTextToInputConnection("Test1")
commitTextToInputConnection("Test2")
service.currentInputConnection.endBatchEdit()
onUpdateSelection is called only once, after all the changes in the block have been made.
I am building an app that displays a bunch of information that the user can edit, and I am having trouble keeping the UI updating the data displaid so it is consistent with the new edits done at runtime.
I have implemented updateUI methods that basically look like:
void updateUI(){
((TextView) fieldDisplay).setText(fieldCurrentValue);
...
}
I know I can run this method in things like an AsyncTask or similar stuff that makes it execute continuously. But Im concerned about efficency since its not really necesary to update the UI all the time, but only when the user inputs a value wich is not that often.
What would be the best approach to this?
EDIT:
The question is how to make sure the an UI element shows the current value of a field, regardless of how or why that field is updated.
My case specifically is the with this. Im trying to make an RPG character sheet, and I have like a bazillion Skills, wich are affected by another lot of fields, such as Characteristics, Modifiers, Categories...
The application should behave so, whenever any of the many fields affects it changes, it should display the new value.
Now, since keeping track of what field affects what is part of the problem, if could update whenever any field whatsoever changes, but I dont know how to do that.
Need your help or advice.
The aim is to get continuous updates from method android.telephony.CellSignalStrengthWcdma.getDbm() (Get the mobile network signal strength as dBm) and make update of correspondent text view when the value provided by the method changes.
The first approach of the solution is to request for value in do-while cycle with predefined time interval, like 1 second, check the difference between common and previous values and make decision of textView update.
So the question is maybe there is some other better way to do this, like using kind of system listener etc?
BR,
You need to add a PhoneStateListener to your TelephonyManager using the proper method listen(). You need to pass a sub class of PhoneStateListener and the event you want to get. For example you can listen for PhoneStateListener.LISTEN_CELL_INFO; in this case the method onCellInfoChanged (List cellInfo) of your PhoneStateListener is called, providing you the info you need, avoiding a loop.
My question is essentially if the value that is in the intent object, when sent through a second time, does it have the same values again, and if so, is there a limit to how many times this can be done?
As we talk about Intent then it is used to Perform any Operation.
e.g intent.putExtra(key1,value);
All depends on the value. If your value is not null then you can use it as many times you want. It has no Limit.
You can use any number of times intent.putExtra(key,value);
but you have to make sure that the value and the key is not null and key is different from previous used keys.