我已在清单中授予 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);}
但什么也没有发生。任何想法为什么?这可能是一件非常愚蠢的事情。我确实检查了我的手机是否在振动并且它在不同的应用程序中。
银河 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);
}