English 中文(简体)
为什么我用电话敲响警钟?
原标题:Why isnt my phone vibrating when i press the button?
  • 时间:2012-01-14 05:37:07
  •  标签:
  • java
  • android

想让用户在一顿点上点击电话。 这里有Seml和Andersibrator。 java如此错? 如何确定? 感谢!

此处为:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="android.app"
    android:versionCode="1"
    android:versionName="1.0" >
      <uses-permission android:name="android.permission.VIBRATE"/>

    <uses-sdk android:minSdkVersion="7" />

    <application

        android:icon="@drawable/ic_launcher"

        android:label="@string/app_name" >
        <activity

            android:name=".AndroidActivity"
            android:label="@string/app_name"
            android:screenOrientation="portrait">

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
         <activity android:name=".activity2"
                   android:screenOrientation="portrait"
                   android:label="@string/app_name"  >


         </activity>

         <activity android:name=".activity3"
                   android:screenOrientation="portrait"
                   android:label="@string/app_name" >

         </activity>

         <activity android:name=".next" >

         </activity>






    </application>




</manifest>

这里指的是:

package android.app;
import android.app.R;
import android.app.Activity;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.view.View;
import android.os.Vibrator;

public class AndroidVibrator extends Activity implements OnClickListener
{
    private View myView;
    private Vibrator myVib;

    @Override
    protected void onCreate(Bundle savedInstanceState)
    {
        super.onCreate(savedInstanceState);
        myVib = (Vibrator) this.getSystemService(VIBRATOR_SERVICE);

        //myView can be any type of view, button, etc.
        myView = (View) this.findViewById(R.id.sound);
        myView.setOnClickListener((android.view.View.OnClickListener) this);
    }

    public void onClick(View v)
    {
        myVib.vibrate(50);
        //add whatever you want after this
    }

    public void onClick(DialogInterface arg0, int arg1) {
        // TODO Auto-generated method stub

    }
}
问题回答

确保你发出呼吁

  <uses-permission android:name="android.permission.VIBRATE" />

阁下

EDIT:

请求在声明的末尾或文本之后批准。

我已就同一事项对你先前的职位作了答复。

此时此刻,你将有关使用许可的 s号......

检查我的其他答案。

Also check the ouput of LogCat. Does your application force closes?

may be 50 ms is too short to feel vibrate try more than 50ms





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签