That sounds interesting. I subscribed to your blog and look forward to
the results.

I am doing the processing as a background activity and don't feel that
WebView is a good fit for me here.

I just use the regular Java 1.4+ regexps. And I have to say that I
wouldn't recommend that. I will very likely build my own parser for
image, stylesheet and background-image tags in the future.
I use Matcher.find() to iterate over the html/stylesheet file.
Unfortunately this can lead to 100% CPU indefinitely
(http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4771934).

Cheers,
Mariano

On Wed, Feb 18, 2009 at 10:18 PM, Mattaku Betsujin
<mattaku.betsu...@gmail.com> wrote:
> Hi Mariano,
>
> Not directly related to your question, but how do you use regexp? Do you use
> the Java API?
>
> I am doing a hobby project that's similar to your app. I use regexp to strip
> all the ads from web pages and reformat them for better display. I actually
> use a WebView to run the regexp using JavaScript. It's a lot easier to code
> than Java. I could add support for a new site (such as yahoo news) in a
> couple of hours.
>
> I have posted some screen shots at
>
> http://nubinewsblog.blogspot.com/
>
> I will upload to Android Market after a few more days of testing. Source
> will be available on SourceForge under Apache 2.
>
>
> On Wed, Feb 18, 2009 at 11:32 AM, Mariano Kamp <mariano.k...@gmail.com>
> wrote:
>>
>> Hi,
>>
>>   I wrote an app that acts as a Google Reader client. It downloads an XML
>> from Google, parses it and afterward analyzes web pages with regular
>> expressions to find image and stylesheet tags to make the pages available
>> offline.
>>
>>   So far so good. The problem is the above mentioned tasks are pretty CPU
>> intensive and I also use gesture to mark items as read etc. The gesture
>> detection gets really bad when done during the synchronization phase (see
>> above).
>>
>>   Those tasks from the synchronization phase are not time critical. I
>> would like to tell the OS that the UI thread is far more important than my
>> background thread. I just don't know how to do that efficiently.
>>
>>  In an ideal world the OS would take care of that for me, so I started out
>> with "Thread.currentThread().setPriority(Thread.MIN_PRIORITY);". That didn't
>> have any obvious effect. Then I sprinkled "Thread.yield()" in all major
>> areas, in particular in the loops. But that also didn't seem to have much of
>> an effect. Before I know start to to all kind of silly stuff, I'd like to
>> pick your brains on how this is done properly?
>>
>>  I am absolutely willing to use Thread.sleep(20) in some of the places I
>> use Thread.yield. A little bit of a pause might be a good thing for the
>> battery heat and power consumption, but I can't let the pause get really
>> long, e.g. 250ms, because I wouldn't get any work done and would keep the
>> phone awake unnecessarily (I am holding a partial wake lock). On the other
>> hand I am not sure if a small pause now and then, like a 20ms pause, then
>> 50ms work, won't take too much a toll on the CPU for switching tasks and in
>> the end burn the battery too fast.
>> Also, what seems like a good pause for the G1 might be not so much of a
>> good idea on different hardware, like a Netbook.
>>
>>   I could try to set the Priority of the UI thread to MAX_PRIORITY, but as
>> I didn't start the thread, I feel that it's not my business to change its
>> priority.
>>
>>   I could check if the screen is off. If that is the case high resolution
>> touch events are not so likely so I could revert all the measurement from
>> above until the screen comes on again.
>>
>>   So what do you think? I guess I am not the only one with the problem, or
>> am I?
>>
>> Cheers,
>> Mariano
>>
>>
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to