我已經爲清單中的VIBRATE授予了權限。在我的應用程序中,我有以下代碼振動不起作用ICS
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_parent_control);
vibe = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE) ;
vibe.vibrate(100);}
但沒有任何反應。任何想法爲什麼?這可能是一件非常愚蠢的事情。我確實檢查了我的手機是否在震動,而且它在不同的應用程序中。
銀河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);
}
請發表您的清單 – XepterX
檢查它是否是工作在按鈕的onClick() –
我有相同的代碼,這就是效果很好 –