Quel est le problème avec mon code - Notification - pas de son, pas de vibration
Me semble que j'ai un problème avec mon code.
J'ai créé un test de l'activité, juste pour voir ce qui ne va pas, je peux pas.
public class test extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String extra = "test";
NotificationManager myNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
Intent intent = new Intent(this, test.class);
Notification notification = new Notification(R.drawable.icon,
extra,
System.currentTimeMillis());
PendingIntent pendingIntent = PendingIntent.getActivity(this,
0,
intent,
PendingIntent.FLAG_UPDATE_CURRENT);
notification.setLatestEventInfo(getApplicationContext(), "title", "text", pendingIntent);
notification.flags |= Notification.DEFAULT_SOUND;
notification.flags |= Notification.DEFAULT_LIGHTS;
notification.flags |= Notification.DEFAULT_VIBRATE;
notification.flags |= Notification.FLAG_INSISTENT;
notification.flags |= Notification.FLAG_AUTO_CANCEL;
myNotificationManager.notify(33, notification);
}
}
Je n'ai pas de son et/ou le vibreur lors de la notification pop.
J'ai regardé les paramètres de mon téléphone, et ils sont ok, pas de silence, son par défaut est activé.
source d'informationauteur Saariko
Vous devez vous connecter pour publier un commentaire.
Ce...
devrait être...
Pour toutes les valeurs par défaut (Son, Vibreur & Light) en 1 ligne de code que vous pouvez utiliser:
c'est l'équivalent de
assurez-vous de définir des autorisations pour vibrer dans votre Manifeste