IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Android Discussion :

Question au sujet d'un tutoriel de création d'application


Sujet :

Android

  1. #1
    Candidat au Club Avatar de Neotendo
    Homme Profil pro
    Webmaster
    Inscrit en
    Août 2016
    Messages
    5
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Webmaster

    Informations forums :
    Inscription : Août 2016
    Messages : 5
    Points : 4
    Points
    4
    Par défaut Question au sujet d'un tutoriel de création d'application
    Hello. Je suis désolé par avance si je débarque comme un cheveu sur la soupe mais j'ai besoin de quelques réponses.

    J'ai le besoin de développer une application Android pour le site web auquel je travaille. C'est une application qui permet de voir une galerie de fonds d'écran pour son mobile et d'en sélectionner un en réglant notamment les dimensions (cadrage). Pour cela j'ai notamment suivi un tutoriel qui date de cette année, de ce site lui-même étant une reprise d'un autre tutoriel plus ancien. Ce tutoriel utilise l'API Picasa toujours fonctionnelle alors Google se concentrer désormais sur son Google Photo.

    Le hic évidemment est que si l'application fonctionne correctement, les fonctions de mise en fond d'écran et de téléchargement du fond ne marchent pas. Mais le pire est que l'application du créateur du tutoriel disponible sur le Play Store a ce même problème, alors que pourtant dans sa vidéo il arrive à appliquer un nouveau fond d'écran et à télécharger les photos. Aucune réponse n'est fait sur l'espace commentaire du site en question, à la seule personne qui parle de ce problème le créateur ne répond pas au problème. J'ai contacté d'autres développeurs qui ont conçu ce genre d'applications, je suis resté sans réponse jusqu'à présent. Etant un piètre programmeur, à peine débutant en java, je ne sais pas ce qu'il faut modifier.

    C'est pour cela que je me tourne vers vous. J'aimerais savoir s'il est possible de m'expliquer où se situe le problème dans la programmation de cette application et comment je pourrais le résoudre. Je m'excuse par avance si le sujet est posté au mauvais endroit ou que je ne me suis pas présenté en bonne et due forme.

    Je vous remercie de votre attention.

  2. #2
    Modérateur
    Avatar de grunk
    Homme Profil pro
    Lead dév - Architecte
    Inscrit en
    Août 2003
    Messages
    6 691
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39
    Localisation : France, Côte d'Or (Bourgogne)

    Informations professionnelles :
    Activité : Lead dév - Architecte
    Secteur : Industrie

    Informations forums :
    Inscription : Août 2003
    Messages : 6 691
    Points : 20 222
    Points
    20 222
    Par défaut
    Picasa est officiellement abandonné depuis ce 1er aout. Donc si le téléchargement des image ne marche pas c'est peut être tout simplement à cause de ça.

    Après sans information de debug , sans message d'erreur , ca va être dur de t'en dire plus.
    Pry Framework php5 | N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

  3. #3
    Candidat au Club Avatar de Neotendo
    Homme Profil pro
    Webmaster
    Inscrit en
    Août 2016
    Messages
    5
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 35
    Localisation : France, Rhône (Rhône Alpes)

    Informations professionnelles :
    Activité : Webmaster

    Informations forums :
    Inscription : Août 2016
    Messages : 5
    Points : 4
    Points
    4
    Par défaut
    Merci pour votre réponse.

    Pour répondre au sujet de Picasa, je le reprécise ici que depuis la période février/mai dernier Google a officiellement déclarer mettre de coté Picasa pour se concentrer sur son autre service, Google Photo, pour des raisons éviden. Ce que j'ai évoqué dans mon précédent message. Cependant, je n'ai aucune information officielle affirmant l'abandonné du service aujourd'hui le 1er Aout. Picasa est toujours en ligne, l'API est actuellement fonctionnelle et j'ai donc toujours accès aux images via l'application. Je ne pense pas que le problème viennent directement de Picasa.

    En fait je n'ai aucune erreur de programmation, Android Studio compile et lance application sans problème. Au contraire je pense que le défaut vient du fonctionnement d'un des scripts java et qu'il faudrait mettre à jour. Quand je clique sur les actions, l'application répond en donnant le message d'erreur programmé dans les scripts java : http://image.noelshack.com/fichiers/...1-120536-1.png

    Alors je ne pense pas que je puisse poster ici l'ensemble des scripts, qui sont sur le lien que j'ai posté sur mon message précédent, mais je vous mets néanmoins ce script car je pense sans aucune conviction que c'est là qu'il faudrait faire quelques modifications :

    Utils.java
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    234
    235
    236
    237
    238
    239
    240
    241
    242
    243
    244
    245
    246
    247
    248
    249
    250
    251
    252
    253
    254
    255
    256
    257
    258
    259
    260
    261
    262
    263
    264
    265
    266
    267
    268
    269
    270
    271
    272
    273
    274
    package com.geekmentors.wallpaperfreeapp.utils;
     
    import android.app.WallpaperManager;
    import android.content.ContentValues;
    import android.content.Context;
    import android.content.Intent;
    import android.database.Cursor;
    import android.graphics.Bitmap;
    import android.graphics.Color;
    import android.graphics.Point;
    import android.net.Uri;
    import android.os.Environment;
    import android.provider.MediaStore;
    import android.support.design.widget.CoordinatorLayout;
    import android.support.design.widget.Snackbar;
    import android.util.Log;
    import android.view.Display;
    import android.view.View;
    import android.view.WindowManager;
    import android.widget.TextView;
     
    import com.geekmentors.wallpaperfreeapp.R;
     
    import java.io.File;
    import java.io.FileOutputStream;
    import java.util.Random;
     
    public class Utils {
        private String TAG = Utils.class.getSimpleName();
        private Context _context;
        private PrefManager pref;
     
        // constructor
        public Utils(Context context) {
            this._context = context;
            pref = new PrefManager(_context);
        }
     
        /*
         * getting screen width
         */
        @SuppressWarnings("deprecation")
        public int getScreenWidth() {
            int columnWidth;
            WindowManager wm = (WindowManager) _context
                    .getSystemService(Context.WINDOW_SERVICE);
            Display display = wm.getDefaultDisplay();
     
            final Point point = new Point();
            try {
                display.getSize(point);
            } catch (java.lang.NoSuchMethodError ignore) {
                // Older device
                point.x = display.getWidth();
                point.y = display.getHeight();
            }
            columnWidth = point.x;
            return columnWidth;
        }
     
        public void reportImage(Bitmap bitmap)
        {
            File myDir = new File(
                    Environment
                            .getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),
                    pref.getGalleryName());
     
            myDir.mkdirs();
            Random generator = new Random();
            int n = 10000;
            n = generator.nextInt(n);
            String fname = "Wallpaper-" + n + ".jpg";
            File file = new File(myDir, fname);
            if (file.exists())
                file.delete();
            try {
                FileOutputStream out = new FileOutputStream(file);
                bitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
                out.flush();
                out.close();
     
                Uri uri = getImageContentUri(_context,file);
                WallpaperManager wallpaperManager = WallpaperManager.getInstance(_context);
                Intent intent = new Intent(Intent.ACTION_SENDTO);
                intent.setType("text/html");
                intent.setData(Uri.parse("mailto:" + "info@geekmentors.com"));
                intent.putExtra(Intent.EXTRA_SUBJECT, "Wallpaper HD: Report Image");
                intent.putExtra(Intent.EXTRA_TEXT, "Write Your Report Below...");
                intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
                Intent chooserIntent = Intent.createChooser(intent,
                        "Report Via");
                chooserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
     
                try {
                    _context.startActivity(chooserIntent);
                }catch (Exception e)
                {
                    e.printStackTrace();
                }
     
            } catch (Exception e) {
                e.printStackTrace();
     
            }
        }
     
        public void shareImage(Bitmap bitmap, CoordinatorLayout coordinatorLayout)
        {
            File myDir = new File(
                    Environment
                            .getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),
                    pref.getGalleryName());
     
            myDir.mkdirs();
            Random generator = new Random();
            int n = 10000;
            n = generator.nextInt(n);
            String fname = "Wallpaper-" + n + ".jpg";
            File file = new File(myDir, fname);
            if (file.exists())
                file.delete();
            try {
                FileOutputStream out = new FileOutputStream(file);
                bitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
                out.flush();
                out.close();
     
                Uri uri = getImageContentUri(_context,file);
     
                // final Intent shareIntent = new Intent(Intent.ACTION_SEND);
                // shareIntent.setType("image/jpg");
                //  shareIntent.putExtra(Intent.EXTRA_STREAM, uri.fromFile(file));
     
                Intent wall_intent =  new Intent(Intent.ACTION_SEND);
                wall_intent.setType("image/*");
                wall_intent.putExtra("mimeType", "image/*");
                wall_intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
                Intent chooserIntent = Intent.createChooser(wall_intent,
                        "Share Using");
                chooserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
     
                try {
                    _context.startActivity(chooserIntent);
                }catch (Exception e)
                {
                    e.printStackTrace();
                }
     
            } catch (Exception e) {
                e.printStackTrace();
                Snackbar snackbar = Snackbar
                        .make(coordinatorLayout, _context.getString(R.string.toast_wallpaper_set_failed), Snackbar.LENGTH_SHORT);
                View sbView = snackbar.getView();
                TextView textView = (TextView) sbView.findViewById(android.support.design.R.id.snackbar_text);
                textView.setTextColor(Color.YELLOW);
                snackbar.show();
            }
     
        }
        public void saveImageToSDCard(Bitmap bitmap, CoordinatorLayout coordinatorLayout) {
            File myDir = new File(
                    Environment
                            .getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),
                    pref.getGalleryName());
     
            myDir.mkdirs();
            Random generator = new Random();
            int n = 10000;
            n = generator.nextInt(n);
            String fname = "Wallpaper-" + n + ".jpg";
            File file = new File(myDir, fname);
            if (file.exists())
                file.delete();
            try {
                FileOutputStream out = new FileOutputStream(file);
                bitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
                out.flush();
                out.close();
                Snackbar snackbar = Snackbar
                        .make(coordinatorLayout,
                                _context.getString(R.string.toast_saved).replace("#",
                                        "\"" + pref.getGalleryName() + "\""), Snackbar.LENGTH_SHORT);
                View sbView = snackbar.getView();
                TextView textView = (TextView) sbView.findViewById(android.support.design.R.id.snackbar_text);
                textView.setTextColor(Color.YELLOW);
                snackbar.show();
                Log.d(TAG, "Wallpaper saved to: " + file.getAbsolutePath());
     
            } catch (Exception e) {
                e.printStackTrace();
                Snackbar snackbar = Snackbar
                        .make(coordinatorLayout, _context.getString(R.string.toast_saved_failed), Snackbar.LENGTH_SHORT);
                View sbView = snackbar.getView();
                TextView textView = (TextView) sbView.findViewById(android.support.design.R.id.snackbar_text);
                textView.setTextColor(Color.YELLOW);
                snackbar.show();
            }
        }
     
        public static Uri getImageContentUri(Context context, File imageFile) {
            String filePath = imageFile.getAbsolutePath();
            Cursor cursor = context.getContentResolver().query(
                    MediaStore.Images.Media.EXTERNAL_CONTENT_URI,
                    new String[] { MediaStore.Images.Media._ID },
                    MediaStore.Images.Media.DATA + "=? ",
                    new String[] { filePath }, null);
            if (cursor != null && cursor.moveToFirst()) {
                int id = cursor.getInt(cursor
                        .getColumnIndex(MediaStore.MediaColumns._ID));
                Uri baseUri = Uri.parse("content://media/external/images/media");
                return Uri.withAppendedPath(baseUri, "" + id);
            } else {
                if (imageFile.exists()) {
                    ContentValues values = new ContentValues();
                    values.put(MediaStore.Images.Media.DATA, filePath);
                    return context.getContentResolver().insert(
                            MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
                } else {
                    return null;
                }
            }
        }
     
        public void setAsWallpaper(Bitmap bitmap, CoordinatorLayout coordinatorLayout) {
     
            File myDir = new File(
                    Environment
                            .getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES),
                    pref.getGalleryName());
     
            myDir.mkdirs();
            Random generator = new Random();
            int n = 10000;
            n = generator.nextInt(n);
            String fname = "Wallpaper-" + n + ".jpg";
            File file = new File(myDir, fname);
            if (file.exists())
                file.delete();
            try {
                FileOutputStream out = new FileOutputStream(file);
                bitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
                out.flush();
                out.close();
     
                Uri uri = getImageContentUri(_context,file);
                WallpaperManager wallpaperManager = WallpaperManager.getInstance(_context);
                //Intent intent = new Intent(wallpaperManager.getCropAndSetWallpaperIntent(uri));
                //_context.startActivity(intent);
                Intent wall_intent =  new Intent(Intent.ACTION_ATTACH_DATA);
                wall_intent.setDataAndType(uri, "image/*");
                wall_intent.putExtra("mimeType", "image/*");
                Intent chooserIntent = Intent.createChooser(wall_intent,
                        "Set As");
                chooserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                try {
                    _context.startActivity(chooserIntent);
                }catch (Exception e)
                {
                    e.printStackTrace();
                }
     
     
     
            } catch (Exception e) {
                e.printStackTrace();
                Snackbar snackbar = Snackbar
                        .make(coordinatorLayout, _context.getString(R.string.toast_wallpaper_set_failed), Snackbar.LENGTH_SHORT);
                View sbView = snackbar.getView();
                TextView textView = (TextView) sbView.findViewById(android.support.design.R.id.snackbar_text);
                textView.setTextColor(Color.YELLOW);
                snackbar.show();
            }
        }
    }
    [EDIT] Je suis d'ailleurs en train de chercher un service très similaire à Picasa, un hébergeur d'image dont l'adresse API comporte des critères comme "user" et "album". Je ne suis vraiment pas à l'aise avec ça, j'ai essayé Imgur ou Cloudinary mais je crois qu'il me faille modifier beaucoup de script.

  4. #4
    Modérateur
    Avatar de grunk
    Homme Profil pro
    Lead dév - Architecte
    Inscrit en
    Août 2003
    Messages
    6 691
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 39
    Localisation : France, Côte d'Or (Bourgogne)

    Informations professionnelles :
    Activité : Lead dév - Architecte
    Secteur : Industrie

    Informations forums :
    Inscription : Août 2003
    Messages : 6 691
    Points : 20 222
    Points
    20 222
    Par défaut
    Pour ton message d'erreur ça ne nous avance pas , c'est dans le logcat que tu auras des erreurs intéressante si il y'en a et à condition que ton appli soit en debug (donc lancée depuis Android Studio).
    Pry Framework php5 | N'oubliez pas de consulter les FAQ Java et les cours et tutoriels Java

Discussions similaires

  1. Réponses: 0
    Dernier message: 14/12/2008, 23h21
  2. Question au sujet de CString
    Par Cédric_07 dans le forum MFC
    Réponses: 12
    Dernier message: 11/05/2006, 15h52
  3. Petite question au sujet du code Hamming
    Par sylsau dans le forum Algorithmes et structures de données
    Réponses: 5
    Dernier message: 28/02/2006, 12h30
  4. Questions au sujet d'une démission
    Par root76 dans le forum Démission
    Réponses: 18
    Dernier message: 22/02/2006, 12h39
  5. Réponses: 2
    Dernier message: 27/07/2004, 14h38

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo