Vibrate in dynamic pattern Code Answer

Hello Developer, Hope you guys are doing great. Today at Tutorial Guruji Official website, we are sharing the answer of Vibrate in dynamic pattern without wasting too much if your time.

The question is published on by Tutorial Guruji team.

I’m coming from Actionscript 3 and new to Java. I’m trying to make a vibrate pattern half of which is fixed and half of which is dynamic. For eg:

long[] vibratePattern = {100,100,100,100} //fixed pattern
if(some_condition) vibratePattern.append(400);
if(some_condition) vibratePattern.append(200);
if(some_condition) vibratePattern.append(100);

But long[] doesn’t have any append or add method.

I tied creating ArrayList but the method Vibrator.vibrate takes long[] as parameter.

So my question is how can I make long[] array with half fixed item and half dynamic item and pass it to Vibrator.vibrate method. Can I create some other list and pass it as long[] to the method?

Answer

I ended up using gauva following this answer: https://stackoverflow.com/a/1698098

So I only had to Longs.toArray(foundLongs);

We are here to answer your question about Vibrate in dynamic pattern - If you find the proper solution, please don't forgot to share this with your team members.

Related Posts

Tutorial Guruji