振动对ICS不起作用

时间:2012-09-25 06:57:43

标签: android vibrate

我已在清单中为VIBRATE授予了权限。在我的应用程序中,我有以下代码

    @Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_parent_control);

    vibe = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE) ;
    vibe.vibrate(100);}

但没有任何反应。有什么想法吗?这可能是非常愚蠢的事情。我确实检查过我的手机是否振动,而且是在不同的应用程序中。

Galaxy s3 ICS-4.0.4

这是清单

import android.os.Vibrator;...


<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="Jino.parentcontrol"
android:versionCode="1"
android:versionName="1.0" >




<uses-sdk
    android:minSdkVersion="14"
    android:targetSdkVersion="15" />

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

<application
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/AppTheme" >
    <uses-library android:name="com.google.android.maps" />
    <activity
        android:name=".ParentControl"
        android:screenOrientation="portrait"
        android:label="@string/title_activity_parent_control" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

这是我完整的onCreate函数。

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_parent_control);

    vibe = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE) ;
    vibe.vibrate(100);
    Connection_Status=0;

    mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();

    // If the adapter is null, then Bluetooth is not supported
    if (mBluetoothAdapter == null) {
        Toast.makeText(this, "Bluetooth is not available", Toast.LENGTH_LONG).show();
        finish();
        return;
    }





    mapview = new MapView(ParentControl.this, getString(R.string.debug_mapview_apikey));
    mapview.setClickable(true);
    mapview.setBuiltInZoomControls(true);
    mapview.setSatellite(true);

    mapcontrol = mapview.getController();
    mapcontrol.setZoom(19);

    myLocationManager = (LocationManager) getSystemService( Context.LOCATION_SERVICE );

    me=new MyCustomLocationOverlay(this, mapview);
    mapview.getOverlays().add(me);


    me.enableMyLocation();
    me.enableCompass();

    CenterMap();

    RelativeLayout layout= (RelativeLayout) findViewById(R.id.my_layout);
    layout.addView(mapview);

    probar=(ProgressBar) findViewById(R.id.progressBar);

    probar.setMax(100);
    probar.setBackgroundColor(Color.BLACK);
    probar.setProgress(100);

}

2 个答案:

答案 0 :(得分:1)

需要在声音中打开触觉反馈 - &gt;振动强度菜单。

答案 1 :(得分:0)

我测试了你的代码。完美无缺。

我有以下内容:

在清单中:

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

在主要活动中

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    Vibrator vibe = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE) ;
    vibe.vibrate(100);
}

尝试增加振动时间?