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

  • SEARCH
  • Home
  • 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 8387519
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:14:03+00:00 2026-06-09T18:14:03+00:00

Im just making a simple app that will vibrate when the button is clicked,

  • 0

Im just making a simple app that will vibrate when the button is clicked, but for some reason when i click the button the app says it unexpectedly stopped and needed to force close, below is the source code to the main java file and i have used the android vibrate permission in my manifest. can someone tell me why every time I click the vibrate button it gives me the error that it unexpectedly stopped?

package com.test;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Vibrator;
import android.view.View;
import android.widget.EditText;

public class Main extends Activity {

public final static String EXTRA_MESSAGE = "com.test.MESSAGE";

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
}

/* Called when the user clicks the button */
public void sendMessage(View view) {
    // do something in response to button
    Intent intent = new Intent(this, DisplayMessageActivity.class);
    EditText editText = (EditText) findViewById(R.id.edit_message);
    String message = editText.getText().toString();
    intent.putExtra(EXTRA_MESSAGE, message);
    startActivity(intent);
}

public void vibrateMe() {


    Vibrator vibrate = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);

    vibrate.vibrate(500);


}

public void stopVibrating(Vibrator vibrate) {

        vibrate.cancel();
    }
}
  • 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-09T18:14:04+00:00Added an answer on June 9, 2026 at 6:14 pm

    You have to change your vibrateMe() to vibrateMe(View v) if you use android:onClick="vibrateMe"

    For instance, if you specify android:onClick=”sayHello”, you must
    declare a public void sayHello(View v) method of your context
    (typically, your Activity).

    Check the developer page

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

Sidebar

Related Questions

I'm just learning Ruby and making a simple Hello World program, put for some
I was making this very simple lex program (just an introductory program). But on
so I'm making some basic programming language (just for exercise). I've made simple grammar
I am making a simple app with a tableview that displays results of a
I'm making a simple fractal viewing app for Android, just for fun. I'm also
I was making a simple class for a small project and decided to just
Okay, I think I'm just making a stupid mistake here, but I want to
I have a somewhat simple game that I'm making and now that I'm testing
What I have is an app that displays some documents. In the string resources
I am making an app that is a standalone menu item and the basis

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.