Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7834967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:25:09+00:00 2026-06-02T13:25:09+00:00

I’m trying to implement a feature into my app where it can pulse the

  • 0

I’m trying to implement a feature into my app where it can pulse the vibrator.
The user can change 3 things, the vibration strength, pulse length, and time between pulses, using sliders.

I was thinking of some code like:

for(i=0; i<(pulse length * whatever)+(pulse gap * whatever); i+=1){
pattern[i]=pulse length*i;
patern[i+1]=pulse gap;

However, when I use this code (when its done properly, thats just a quick example) it crashes the app. Also, when I change the vibration strength (which does work) I have to restart the service for the strength to change. The way I change the strength is by altering the time the vibrator turns on ands turns off for in a pattern.

This is the code I use for detecting how the phone should vibrate (the code in here is a little different to what I would prefer):

if (rb == 3){
    z.vibrate(constant, 0);
} else if (rb == 2){
     smooth[0]=0;
     for (int i=1; i<100; i+=2){
           double angle = (2.0 * Math.PI * i) / 100;
           smooth[i] = (long) (Math.sin(angle)*127);
           smooth[i+1]=10;
     }
     z.vibrate(smooth, 0);
} else if (rb == 1){
     sharp[0]=0;
     for(int i=0; i<10; i+=2){
            sharp[i] = s*pl;
            sharp[i+1] = s+pg;
     }
     z.vibrate(sharp, 0);
}
} else {
        z.cancel();
}

If anyone’s able to point me in the direction of some code that can do this, or how I can make it work, I would appreciate it very much.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T13:25:10+00:00Added an answer on June 2, 2026 at 1:25 pm

    The only guess I have is that you are receiving an ArrayIndexOutOfBounds error.

    If so, you need to define the length of your long arrays before trying to fill them.

    long[] OutOfBounds = new long[];
    OutOfBounds[0] = 100;
    // this is an error, it's trying to access something that does not exist.
    
    long[] legit = new long[3];
    legit[0] = 0;
    legit[1] = 500;
    legit[2] = 1000;
    // legit[3] = 0; Again, this will give you an error. 
    

    vibrate() is a smart function though. Neither of these examples throw an error:

    v.vibrate(legit, 0);
    // vibrate() combines both legit[0] + legit[2] for the 'off' time
    
    long tooLegit = new long[100];
    tooLegit[0] = 1000;
    tooLegit[1] = 500;
    tooLegit[10] = 100;
    tooLegit[11] = 2000;
    v.vibrate(tooLegit, 0);
    // vibrate() skips over the values you didn't define, ie long[2] = 0, long[3] = 0, etc
    

    Hope that helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
I would like to count the length of a string with PHP. The string
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I am trying to render a haml file in a javascript response like so:
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.