Convert ios Swift functions to java(android)
<p>I have an ios app working, I am writing same app in android by converting code from swift to java.</p>

<p>I have following functions in swift:</p>

<pre><code>func testVibration()
{
var value = getVibrationByte(true)
let data = NSData(bytes: &amp;value, length: sizeof(UInt8))
...
...
}
</code></pre>

<p>and </p>

<pre><code>private func getVibrationByte() -&gt; UInt8
{
   //here I have some conditions to determine below value variable, but those I those I managed to convert, so directly providing 128 value.
    var value = 128
    return UInt8((value + 2 &lt;&lt; 2) + 1)
}
</code></pre>

<p>My query is:</p>

<p>I converted below line:</p>

<pre><code> let data = NSData(bytes: &amp;value, length: sizeof(UInt8))
</code></pre>

<p>As</p>

<pre><code>byte[] data = ByteBuffer.allocate(1).putInt(value).array();
</code></pre>

<p>Is this correct ? because I am getting "Application Not Responding" error at this line. If not what should be the correct conversion in java for above swift line.</p>

<p>I have tried so many things whole day but no luck. </p>