I have a problem. I'm using a FileObserver, which moves new files from the watched directories to another, former specified directory. In my thoughts there should be shown a toast message that says 'File xy has been moved', as long as the observer watches the directory, also if the applications is only in the background. But I didn't get it working.
It always tells me, that there is a RuntimeException, and that it cannot been done without calling Looper.prepare().
05-11 13:21:28.484: WARN/System.err(3397): java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()
I tried the way with using an handler too, but I also didn't get it to work.
Has someone else an idea? Thanks in advance.
Best regards, Tobi
Before your Toast statement add the following :
runOnUiThread(new Runnable() {
public void run()
{
Toast.makeText(getApplicationContext(), text, Toast.LENGTH_SHORT).show();
}
});
This will make it run on UI thread. Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With