# Solution for handler deprecated

**URL:** <https://discourse.processing.org/t/solution-for-handler-deprecated/35587>\
**Category:** Processing for Android\
**Created:** [March 6, 2022, 5:59am UTC](https://discourse.processing.org/t/solution-for-handler-deprecated/35587 "2022-03-06T05:59:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Myrdalm](https://avatars.discourse-cdn.com/v4/letter/m/bcef8e/32.png) [@Myrdalm](https://discourse.processing.org/u/Myrdalm)\
**Post date:** [March 6, 2022, 5:59am UTC](https://discourse.processing.org/t/solution-for-handler-deprecated/35587/1 "2022-03-06T05:59:00Z")

</div>

My code when using processing 3 works with the previous handler code: But for processing 4, it indicated handler deprecated. I am trying to fix the code but I could not fix it until not. Any solution to fix the code could be much appreciated. Below is the current structure of the code that I could not solve:

private final Handler mHandler = new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {  
@Override  
public void handleMessage(Message msg)  
{  
switch (msg.what)  
{  
case MESSAGE\_WRITE:  
break;  
case MESSAGE\_READ:  
byte[] readBuf = (byte[]) msg.obj;  
readMessage = new String(readBuf, 0, msg.arg1);  
break;  
}  
}  
}, 1000);

---

<div class="post-metadata">

**Author:** ![Rupesh\_Kumar](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/rupesh_kumar/32/12638_2.png) [@Rupesh\_Kumar](https://discourse.processing.org/u/Rupesh_Kumar)\
**Post date:** [May 12, 2022, 10:16pm UTC](https://discourse.processing.org/t/solution-for-handler-deprecated/35587/2 "2022-05-12T22:16:53Z")

</div>

Based on the information [here](https://developer.android.com/reference/android/os/Handler) on android official documentation. You can try -  
`new Handler(Looper.myLooper())`

All the best,  
Rupesh
