2017-07-11 4 views
0

J'ai créé une application il y a quelques années, cependant, je viens de mettre à jour Android Studios, par conséquent, mon code pour la notification ne fonctionne pas comme Android ne l'utilise pas dans les dernières versions du SDK. utiliser Notification.Builder avec mon code, cependant, je reçois une erreur, donc quelqu'un peut m'aider s'il vous plaît.ne peut pas résoudre symbole (contentIntent)

L'erreur que je reçois est cannot Resolve symbol (contentIntent);

String ns = Context.NOTIFICATION_SERVICE; 
mNotificationManager = (NotificationManager) getSystemService(ns); 

Notification.Builder builder = new Notification.Builder(mContext) 
    .setSmallIcon(R.drawable.ic_launcher) 
    .setContentTitle("Fall Detector") 
    .setContentText("Running") 
    .setContentIntent(contentIntent); 
builder.build(); 
Notification notification = builder.getNotification(); 

mNotificationManager.notify(1, notification); 
+0

La duplication possible de [setLatestEventInfo ne peut pas être résolue] (https://stackoverflow.com/questions/32450449/setlatesteventinfo-cannot-be-resolved) – Sufian

+0

Sufian pouvez-vous s'il vous plaît réécrire ma méthode pour moi pendant que je me bats . Merci – user8162255

+0

Quelle erreur recevez-vous lorsque vous essayez le Notification.Builder? (Vous avez écrit "une erreur") –

Répondre

0

Cela devrait fonctionner:

Notification.Builder builder = new Notification.Builder(mContext); 
builder.setSmallIcon(R.drawable.ic_launcher) 
builder.setContentTitle("Fall Detector") 
builder.setContentText("Running") 
builder.setContentIntent(contentIntent); 
builder.build(); 

Notification notification = builder.getNotification(); 

mNotificationManager.notify(1, notification); 
+0

Greaper cela ne fonctionne pas car il ne peut pas résoudre (contentIntent); – user8162255

+0

@ user8162255 Assurez-vous que contentIntent une instance est de [PendingIntent] (https://developer.android.com/reference/android/app/Notification.Builder.html#setContentIntent (android.app.PendingIntent)) – Greaper

+0

Plus cher j'ai réécrit le code vérifie ma question, cependant, il dit toujours incapable de résoudre (contentIntent); – user8162255

0

où est variable ur contentIntent? capture d'écran