I am changing my boot animation images but problem is repeating same images again & again this is des0 file . This is my dess0 file. Please tell me the purpose of this file? How do I set my interval?? I containing my bootanimation.zip file have 2 things a folder which contain 40 pics and desc0.text file which contain this which is below. Please tell me how do I set my interval???
how do I set my boot animation interval
1024 600 10
p 0 0 part0
p 1 0 part1
There could be any number of problems, first: according to your desc there should be three things in your zip namely, desct.txt, part0 and part1 folders. The numeric sequencing of files are very important. Also, the first loop is infinite so you'll get problems reaching part1.
I suggest follow the tutorial as explained in this XDA thread.
Related
I have a location service in my app. For debug purposes, i want to log (to text file) some events like "new coordinate", "service onDestroy", "service onStartCommand", "coordinate sent to backend", and so on.
But im facing with a problem. The log file gets 350+ new lines each day .. so.. in 3 days i have a file with 1000 lines.
My idea is to maintain only the 3 (or N in that case) last days and delete the content that was written 3+ days ago.
But:
I don't want to check in every write if there are old lines to be removed
I don't want to set an alarm that fires every 3 days to erase the old data.
Can you please tell me if you know another efficient way to handle this situation?
Without a way to index into the text file, there's really no way to solve it without reading each line of the file (up to a certain point), parsing it and finding the date.
Don't keep a file. Keep a database. Have one of the columns be "created time". Then you can easily delete the rows that with a created time older than some threshold.
getContentResolver().delete(
yourUri,
"created_time < ?",
new String[] { System.currentTimeIllis() - Integer.toString(TimeUnit.DAYS.toMillis(3)
);
(Or something, please test your own SQL ...)
As a side note, a 1,000 line text file is nothing. Reading and parsing it is not significant unless you are doing it often. If you read and trimmed the file 1x per day, no problem.
Another solution would be to rotate the files (log --> log.1, log.1 --> log.2, ..., log.n-1 ---> log.n). This of course doesn't set a hard limit on the size of any particular file.
In my app, I receive some files. At the beginning I just have the size of this file. So I create an empty file (filled of 0). After creating this file, I will receive 1024 bytes per seconds. Thoses bytes chunks correspond to file parts.
So I need to replace the current content of the file by the bytes I'm receiving.
This means I have to read/write the file every seconds. For small files, it's not a problem, but sometimes I'm having big files (>2Mo).
I searched but I couldn't find a way to replace a part of file at a given index without reading and reaching the while file everytime. Is there any simple solution and performance friendly?
After trying so much things with OuputStream, FileChannel, etc... and post this question. I finally found the "RandomAccessFile" class that solves my problem.
https://docs.oracle.com/javase/7/docs/api/java/io/RandomAccessFile.html
I am beginner and trying to write some calculations with App Inventor 2.
I am trying to write a code to calculate Net present value.
The formula of NPV = - investment + CF/(1+i)power up by years of investment, which means if years of investment are > 1 the second part of formula will repeat until it reached the number of years.
I successfully code the formula for one year that works correct, but have problem with the "repeating" the second part powered by number of years.
I tried to declare years as variable to use it as powering number but think something is wrong with it.
In my opinion I need to split the powering number somewhere to memory and then increase it by 1 until the required number. However have no clue how to do it.
Can anyone help?
Screenshot of the blocks
Following the calculation from the NPB Calculator,
this is converted into blocks the following
Note: for a better clarity and to avoid such long calculation blocks as in your screenshot, I used External Inputs instead of Inline Inputs, which is the default. You can switch that from the context menu after doing a right mouse click onto one of the calculation blocks.
EDIT: screenshot updated for changing cashflows using a list.See also
How to work with Lists by Saj and
How to work with Lists and Lists of lists (pdf) by appinventor.org
i just used the searchabledictionary sample of android, which is available in samples folder of android sdk for windows. ( API level 9 )
i completed the definitions.txt file with the same format like
key - value
when i type a word in search area, the app tries to suggest words, but it doesn't find the exact word.here is an example. i searched the word test , and this is definitions.txt :
acceptance test - meaning
acid test - meaning
alpha test - meaning
benchmark tests - meaning
....
flight test - meaning
load test - meaning
....
test - meaning
it finds 15 first words of this list, ( hopefully it doesn't search words like attestaion) but it doesn't show the exact word test !
i read the DictionaryProvider and DictionaryDatabase but i could not realize the root of problem!
the question is how can i suggest the exact word test at first of the list?
Check Dictionary.java, you will see loadWords function.
That function opens definitions.txt file and iterates all lines, and splits every line with "-" and adds to a Hashmap dictionary.
And again in same file there is getMatches function, which takes your search keyword and gets result from dictionary.
Not sure but because when you are searching a suggestion, first couple of matches displays.
And because of "test" keyword exists on too many lines and ("test - meaning") is your last definition, you can't see on suggesting list.
You could try to move "test -meaning" line to the very first line on definitions.txt.
I have a list of 1000 words. I need to load an array with n randomly chosen words from that list (no repeats allowed). What is the best way of going about doing that?
My ideas:
1) Load the words into R.arrays to create a String array. Use collections.shuffle to shuffle the array, then pull the first n entries from it. Right now, I am having memory issues loading the initial array with the 1000 words using this method.
2) Load the words into a text file, read each word into a String array. Use same method to get first n entries.
3) Hard code the input of the words into a String array (I'd use a script to get that output of course). Use same method to get first n entries.
Is there a better way?
If you're mainly worried about memory usage and you're willing to give up computation speed, here's an algorithm that will get you there.
Keep your words in a text file, one word per line, with a fixed amount of characters per word, padding each word with spaces at the end to ensure a fixed word char size, call it s.
Create an array of max size n, call it w
Open a stream reader to the file containing the 1000 words
Get a random number between 1 and 1000, call it k
Seek to position k*s in the file stream and grab the next s characters
Add the word to w if it does not exist in the array yet
If the w array is full (ie. size=n), we're done, otherwise go back to step 3
Let us know how it goes. Happy coding!