Aller au contenu
View in the app

A better way to browse. Learn more.

Forum de Frandroid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Problème d'alertdialog

Featured Replies

Posté(e)

Salut à tous!

J'ai un petit problème concernant l'affichage d'une alerte dialog

J'obtient le warning suivant... et c'est tout, rien d'autre

07-01 09:54:55.271: WARN/InputManagerService(76): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@438b0780

Le contexte est le suivant :

J'ai une classe GPS, avec un location listener

Lorsque la location change, j'affiche une alerte (à des fins de test)

Pour éviter l'affichage à chaque fois, je vérifie que celle ci n'est pas affiché.

Voici comment je me débrouille avec l'alerte dialog

public class Alerte {
   private Context context;
   private AlertDialog.Builder msg;
   private AlertDialog aPoint;

   public Alerte(Context c) {
       this.context = c;
       msg = new AlertDialog.Builder(context);
       aPoint = msg.create();
   }

   public void alerteRestaurant(final Restaurant restaurant){
       LayoutInflater factory = LayoutInflater.from(context);
       final View diagView = factory.inflate(R.layout.restaurant, null);

       ImageAdapter imgadp = new ImageAdapter(context, 2, live.getIdType(), 0);
       GridView gridview = (GridView) diagView.findViewById(R.id.gridviewPictos);

       gridview.setAdapter(imgadp);
       gridview.setSelector(new ColorDrawable(Color.TRANSPARENT));

       TextView voie = (TextView) diagView.findViewById(R.id.sur);

       voie.setText(context.getGps().getVoie());

       aPoint.setIcon(R.drawable.logo);
       aPoint.setTitle(restaurant.getType() + "(" + restaurant.getIdRestaurant() + ")");
       aPoint.setView(diagView);
       aPoint.setMessage("ok");
       aPoint.setCancelable(false);
       aPoint.setButton("Appeler", new android.content.DialogInterface.OnClickListener() {

           @Override
           public void onClick(DialogInterface arg0, int arg1) {
               context.getRestaurant().appeler("" + restaurant.getTel());
           }
       });

       aPoint.show();
   }

   public AlertDialog getaPoint() {
       return aPoint;
   }
}

Grâce au debugger, je suis sur que le programme s'exécute correctement, seulement le aPoint.show(); me revois un warning :(

Avez une petite idée car je sèche complétement depuis 2 jours :(

Merci à vous et bonne journée!

Posté(e)

Un truc faux dans la doc Android en revanche, il faut impérativement fournir une Activity dans le constructeur du Builder, et non getApplicationContext()

Posté(e)
  • Auteur

Salut Nivek!

Je ne reviens que maintenant après un long weekend!

J'adapte de suite mon code et reviens poster le résultat

Merci pour ta réponse!

EDIT : Problème réglé, j'ai rajouté un attribut boolean dans ma classe Alerte initialisé à false avec un getter qui remplace l'attribut isShowing de aPoint et donc j'ai rajouté aPoint.create() avant chaque aPoint.show().

Merci encore à toi pour ta réponse!

Modifié par com.hero

Archivé

Ce sujet est désormais archivé et ne peut plus recevoir de nouvelles réponses.

Account

Navigation

Rechercher

Rechercher

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.