Coder Social home page Coder Social logo

Comments (7)

dnlbauer avatar dnlbauer commented on July 17, 2024

Toast's sollten immer im Application context ausgeführt werden damit sie unabhängig von der activity lifecycle sind: http://developer.android.com/guide/topics/ui/notifiers/toasts.html#Basics

Toast.makeText(TucanMobile.getApplicationContext(), "Keine Internetverbindung", Toast.LENGTH_LONG).show(); sollte das problem beheben.

from tucanmobile.

dnlbauer avatar dnlbauer commented on July 17, 2024

Oder liegt es vielleicht daran das der Toast hier in einem AsyncTask erzeugt wird? Normalerweise darf man ausserhalb des MainThreads keine GUI-Operationen ausführen. Bin mir jetzt aber nicht sicher ob Toasts dazuzählen. Dann müsste man die alle auslagern, zB in ein publishProgress(..)

from tucanmobile.

Tyde avatar Tyde commented on July 17, 2024

Ja das muss ich ausbessern, aber ich glaube das reicht nicht. Der Fehler tritt auf, da der Toast eben innerhalb von AsyncTast ausgeführt wird. Deswegen mach ich Handler rein, welche dann im GUI Task ausgeführt werden.

Edit: Ja genau das von deinem 2. Kommentar

from tucanmobile.

dnlbauer avatar dnlbauer commented on July 17, 2024

Kann gerade nicht testen aber versuch mal die Toasts durch publishProgress(int errorCode) zu ersetzen, zusammen mit der methode:

@Override
protected void onProgressUpdate(Integer... errorCode) {
    switch(errorCode[0])
    {
        case 1:
            Toast.makeText(TucanMobile.getApplicationContext(), .....)
            break;
        case 2:
            //.......
    }
}

und dann eben für jeden fehler einen anderen errorcode, oder direkt strings an onProgressUpdate übergeben.

onProgressUpdate läuft immer im MainThread, somit sollte das das problem lösen.

from tucanmobile.

Tyde avatar Tyde commented on July 17, 2024

Ich mach es einfach mit Runnables. Der Fehler ist leicht zu fixen: http://stackoverflow.com/questions/3875184/cant-create-handler-inside-thread-that-has-not-called-looper-prepare

from tucanmobile.

dnlbauer avatar dnlbauer commented on July 17, 2024

joa das ist im grunde genau das was onProgressUpdate im hintergrund macht :>

from tucanmobile.

Tyde avatar Tyde commented on July 17, 2024

So funktioniert jetzt mit e7025c5

from tucanmobile.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.