2

I wrote an Android app that receives UDP packets (that are being streamed) and plays then right when they are received. The app works fine until I click on another app on the Android cell phone, at that time I can hear clicking noise.

Is there any way to get ride of this? I thought if I can assign a high priority to the thread responsible to receive and play packets, or if I can assign a high priority to this app may help this.

tshepang
  • 12,111
  • 21
  • 91
  • 136
TJ1
  • 7,578
  • 19
  • 76
  • 119

1 Answers1

1

If you are trying to change the priority of native threads, then this Post might help you.

Community
  • 1
  • 1
Sahil Mahajan Mj
  • 11,033
  • 8
  • 53
  • 100
  • I tried to use: `Thread.currentThread().setPriority(0);` but my app now force closes. – TJ1 Nov 14 '12 at 14:20
  • Bit late now, but most likely an IllegalArgumentException. Use the constants in the [Thread](http://developer.android.com/reference/java/lang/Thread.html#setPriority(int)) class, such as `Thread.MIN_PRIORITY` (value _1_), or `Thread.MAX_PRIORITY` (value _10_). – Barry O'Neill Jun 04 '13 at 00:57
  • @cafelatte It says in the docs for MAX_PRIORITY that is corresponds to Process.THREAD_PRIORITY_URGENT_DISPLAY but is NOT the same value. Coincidentally, I was testing a VPN application which network throughput was limited by CPU performance. When I used the Thread.MAX_PRIORITY value I managed to get 6mbit/s, whereas with the THREAD_PRIORITY_URGENT_DISPLAY I was able to maintain a throughput around 25mbit/s. Thus in my specific case, it seems like URGENT_DISPLAY gives better performance. – Simon Langhoff Nov 27 '14 at 01:47