Cannot get TextLayoutCache value - android

I've got an Android app that consumes a REST webservice that can return a large amount of data as a JSON string. The data is then displayed in its raw form in a TextView.
The app works fine when its a small amount of data, but for a large amount of data I get an error in LogCat that says "Cannot get TextLayoutCache value".
I know that it has to be something to do with space in the TextView but I'm wondering if anyone has any further knowledge so I can figure out the best way to get around this.

This can be fixed by specifying a maxLength for the TextView, e.g.:
android:maxLength="9000"

I had this issue when trying to output a very large (~64K long) text string to WebView alert box.

Related

How to Make Phone Number in String Clickable Kotlin

I have a string and I want to make the value clickable but want to avoid using XML so I want to be able to do it programmatically in the View Holder.
Given: This is a string and I want to to call this number 777-888-9999 there might be stuff here
Output: Same string output but with the phone number clickable and underlined
Currently I am trying using Linkify but am having troubble with having this value to output the same as before. I was able to have it work but for some reason on some devices it doesn't work (it worked well using Linkify.ALL but this was depreciated)

Filter url JSON results using App Inventor 2

I'm trying to filter a JSON url results using App Inventor 2, following sample codes from here1 and here2, but I still cannot get it done right. I only get one result at a time.
The JSON results are data in the form shown in the following figure:
{
"field1":"alphaNumeric1",
"field2":"aNumber1",
"field3":"DD/MM/YY",
"field4":"HH/MM/SS",
"field5":"https://",
"field6":"aText",
"field7":"aNumber2",
"field8":"alphaNumeric2",
"field9":"aNumber3",
"field10":"alphaNumeric3"
}
The JSON url is constantly updated, so are the results, but this is not a problem for now. I can get it read by a timer.
The problem is that from the above results, I need to parse "field2", "field5", "field6", in according labels in the app.
So e.g., when I input a "aNumber1" to get searched in the JSON data, and have the result in a label.
Is it possible this JSON data search be done with App Inventor 2?
Anyone kind enough please answer with a sample blocks if possible.
Thank you all in advance!
[EDIT 1]
No matter what I've tried, JSON could not get filtered right. Therefore I'm to filter the url results in XML.
The XML results are data in the form shown in the following figure:
<results>
<decision>
<alphaNumeric1>ABC1D</alphaNumeric1>
<aNumber1>ABCD</aNumber1>
<aDate>123</aDate>
<doc>HTTP</doc>
<aNumber2>1234</aNumber2>
<alphaNumeric2>TYPE</talphaNumeric2>
<aNumber3>12345</aNumber3>
<aNumber4>1234567</aNumber4>
<aText>SomeText</aText>
<aHour>00:00:00</aHour>
</decision>
.
.
.
<decision>
.
.
.
</decision>
.
.
.
</results>
I have tried to follow the example at here2, but I don't get it right. According to the XML output, what should I put in starTag and endTag, to get a parsing result if I'm searching for e.g. aNumber4 value (= 1234567) ?
Can someone respond with an answer?
[EDIT 2]
Well I'm trying to make some progress here following the example at here3.
The XML is being parsed with a runtime error "this is not a well formatted list of pairs".
Following is the blocks code I'm using:
Why is that so, since I'm following the example to the letter? Any clues anyone to solve this out?
well, your blocks look a little bit strange...
you have a complex list of lists, just use Do it to find out, how it looks like after each step of using lookup in pairs...
It helps to follow the already provided links:
how to work with lists
how to work with list of lists (pdf) by appinventor.org
see also An example of a complex List of Lists
In the example blocks below I looked for the first <decision> and displayed the value of tag aDate in Label1 like this
you might want to loop through the different <decision>s using a for each in list loop....

How would I go about displaying data from an API website and putting it in text format on an activity page?

I want to show data in a sensible form for my movie database app. The website I am using to extract data from is www.omdbapi.com. I have already created a code that extracts the title and year of the movies and displays it in a ListView form which contains items that are all clickable to another activity. I would like each activity that the ListView item clicks to to display the movie information under different headers etc.
I have been stuck on this issue all day. I'm new to coding and have no clue what most processes are called etc. Im not asking for the entire code, just instructions on what to do because I am stumped. I would be very very grateful.
Thank you.
Depending on the format the response is formatted you would either use (probably) an xml parser or a JSON parser and grab the info between specific xml tags or the specific keys within the JSON output.
There are thousands of examples of both methods. If you can get the title to display, then you already know how to get the other elements.

Decode JSON base64 data (from PHP's base64_encode) in Android?

This is my JSON code. Note the title field is base64_encoded. I want to get this title field value.
{"item":{"id":"1","title":"ZGVtbyBkZXNjcmlwdGlvbiBkZW1vIGRlc2NyaXB0aW9uIA==","status":"1"}},
{"item":{"id":"4","title":"ZGVtbyBldmVudCBmb3IgZGVtbyBkZXNjcmlwdGlvbg==","status":"1"}}
{"item":{"id":"6","title":"ZGVtbyBkZXNjcmlwdGlvbiBkZW1vIGRlc2NyaXB0aW9uIA==","status":"1"}}
The title text is in base64 format (ZGVtbyBkZXNjcmlwdGlvbiBkZW1vIGRlc2NyaXB0aW9uIA==) but I would like to get it as normal text -- how can I do this easily?
Thanks.
unfortunately the entire point of encryption is to stop people from doing this...
If you are legally obtaining the encrypted data, try getting in touch with the server team or checking their documentation to find out how they encrypt and how you should decrypt.
There isn't a one size fits all solution for this problem. The answer is 100% dependent on how the String is encrypted in the first place.
good luck!

String and character sequence error (force close) Android

I am facing a problem in solving this issue.
I have 30 smiley images. In a grid view I display all the 30 images. So when I select the image based on the position of the image, the corresponding special character will be displayed from SQLite DB. Before I send message to service it is like "hi :)". What I need is to replace the ":)" with the corresponding smiley image in the local folder of my project (eg. R.drawable.facea.png). I am able to fetch the data and replace ":)" with "aaaaa"(example). But when I try to replace the ":)" with Char Sequence (Image), I get 'force close error'. Where am I going wrong?
I have a function to draw image and I get image as in Character Sequence. How can I use the value in this function globally. I also tried to create a global variable and use the CS value globally. But I still get 'force close error.
You need to use a span (specifically an ImageSpan) to be able to embed bitmap in a string. I have written about this on my blog which also covers some common pitfalls.
If you still cannot get it to work I would suggest posting the precise details of what is going wrong: i.e. your code, and the stacktrace that is getting dumped to logcat.

Categories

Resources