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.

apllication android hors ligne

Featured Replies

Posté(e)

Bonjour,

J'ai crée une application android avec android sdk eclipse , mon application se connecte a une base de donnée externe mysql à l’aide des fichiers php ,
mon application marche seulement en ligne(avec internet) ,maintenant je cherche une solution pour que mon application fonctionne en offline(sans internet)  .

J’ai trouvé la solution android sharedpreferences mais j’arrive pas a l’appliquer pour ce code.

Le code :

public void onStart() {
        super.onStart();
        BackTask bt = new BackTask();
        bt.execute();
    }
 
    private class BackTask extends AsyncTask<Void, Void, Void> {
        ArrayList<String> list1;
 
        protected void onPreExecute() {
            super.onPreExecute();
            list1 = new ArrayList<String>();
        }
 
        protected Void doInBackground(Void... params) {
            InputStream is = null;
            String result = "";
            try {
                URL url = new URL("http://mondomaine.com/exemple.php");
                urlConnection = (HttpURLConnection) url.openConnection();
                urlConnection.connect();
                is = urlConnection.getInputStream();
 
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                BufferedReader reader = new BufferedReader(new InputStreamReader(is, "utf-8"));
                String line = null;
                while ((line = reader.readLine()) != null) {
                    result += line;
                }
                is.close();
 
            } catch (Exception e) {
                e.printStackTrace();
            }
 
            try {
                JSONArray jArray = new JSONArray(result);
                for (int i = 0; i < jArray.length(); i++) {
                    JSONObject jsonObject = jArray.getJSONObject(i);
             
                    list1.add(jsonObject.getString("nom"));
 
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }
            return null;
        }
 
        protected void onPostExecute(Void result) {
            listItems1.addAll(list1);
            adapter1.notifyDataSetChanged();
        }
    }

 

 

Modifié par hima

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.