1

I am developing an App for a smartwatch using Android 6.01 API 23. I want to add some vibration capabilities. I have defined in my AndroidManifest.xml the following:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="myexample.warehousehelper.mobile">

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

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity
        android:name=".MainActivity"
        android:label="@string/app_name"
        android:theme="@style/AppTheme.NoActionBar">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
</application>

I am getting the following exception

java.lang.RuntimeException: Unable to start activity ComponentInfo{myexample.warehousehelper/myexample.warehousehelper.wear.MainActivity}: 
java.lang.SecurityException: Requires VIBRATE permission

The "vibration call" is as follows:

Vibrator v = (Vibrator) getSystemService(VIBRATOR_SERVICE);
v.vibrate(200);

Any hint why is this behaviour?

Luixv
  • 8,590
  • 21
  • 84
  • 121

1 Answers1

1

Well, it is extremely painful to admit that i've posted the wrong Manifest. I've granted the permission to the mobile version and not to the wear version. That is, I used the wrong Manifest.xml.

Now it is working properly without doing anything but the permissions.

Thanks for the help.

Luixv
  • 8,590
  • 21
  • 84
  • 121