• 10

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191


File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

Since yesterday I have an issue on Android 4.2 when I receive push notifications it requires the permission even if i don't set it to vibrate

Notification notification = new Notification(icon, notificationItem.message, when);
notification.setLatestEventInfo(context, "App", notificationItem.message,
            PendingIntent.getActivity(context, 0, intent, 0));
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.defaults |= Notification.DEFAULT_SOUND;

NotificationManager nm =
nm.notify(notificationItem.notificationID, notification);

the exception is raised by nm.notify

I have this issue in two different apps and i never modify the code

    • i don't want to do that, I don't want the notification to vibrate, as you can see I don't set it in the defaults, again it happens only on Android 4.2
    • Have the same issue. It is really a new permission that is required for 4.2 - for my part I'll simply add the vibrate permission for now, but you are right that it shold not be needed in your case. I would raise an issue....
      • 2
    • @Ste - Just got a crash report from the market, where it happened a SGS4 (4.3). I don't set vibration either.

I got the same Exception in Jelly Bean 4.1.2, then following changes I made to resolve this

1.added permission in manifest file.


2.Notification Composing covered by Try-Catch

        mNotificationManager = (NotificationManager)          
        NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(
                .setStyle(new NotificationCompat.BigTextStyle().bigText(msg))
                .setDefaults(Notification.DEFAULT_SOUND | Notification.DEFAULT_VIBRATE);
            mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
            Log.d(TAG, "---- Notification Composed ----");
    catch(SecurityException se)
    catch(Exception e)
  • 41
Reply Report
      • 1
    • Isn't either 1 or 2 sufficient to fix this problem. I'd prefer only 1, if your users will be OK with a bit of permission creep.
    • @Diederik see the answer I have shared is best practices for handling this issue in my eyes, its up-to you how you want do it, No matter 1 or 2, app should work on all the device is the need

Since this bug only occurs on Android 4.2 and 4.3 you might use this as a workaround (i.e. include the maxSdkVersion):

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

Note: the maxSdkVersion attribute was only added in API level 19, which in this case is luckily exactly the minimum we want! In theory we could put any value <= 18 to get the same effect, but that would be nasty.

  • 30
Reply Report
      • 1
    • can you confirm that above declaration with android:maxSdkVersion="18" attr will let install app on devices without Vibrator? because line with only causes app (update) not available
      • 1
    • I don't know, but in terms of allowing installation, I believe only uses-feature (not uses-permission) affects that.