Questions tagged [android-looper]

In Android, a Looper is used to run a message loop for a thread since threads by default do not have a message loop associated with them.

Class used to run a message loop for a thread. Threads by default do not have a message loop associated with them; to create one, call prepare() in the thread that is to run the loop, and then loop() to have it process messages until the loop is stopped.

Most interaction with a message loop is through the Handler class.

This is a typical example of the implementation of a Looper thread, using the separation of prepare() and loop() to create an initial Handler to communicate with the Looper.

class LooperThread extends Thread {
    public Handler mHandler;

    public void run() {
        Looper.prepare();

        mHandler = new Handler() {
            public void handleMessage(Message msg) {
                // process incoming messages here
            }
        };

        Looper.loop();
    }
}

More Info

167 questions
-6
votes
3 answers

How do i stop loop

I am creating a Sms spamming app that will send a user defined number of sms to a specific number. for (i = counter; i > 0; i--) { SmsManager smsManager = SmsManager.getDefault(); smsManager.sendTextMessage(phoneNo,…
Maaz
  • 65
  • 1
  • 11
1 2 3
11
12