Android Studio Bluetooth App Problem

SeboSapienz

Mitglied
Hallo,
ich habe ein Problem mit meiner Bluetooth App.
Es ist im Grunde nur eine App, die eine Zahl per Bluetooth verschicken soll.
Eigentlich funktioniert fast alles, bis auf eine Stelle.

Java:
mLangsamer.setOnClickListener(new View.OnClickListener() {
    public void onClick(View v){
        View view = getView();
        if (null != view) {
            TextView textView = (TextView) view.findViewById(R.id.edit_text_out);
            textView.setText("2");
            String message = textView.getText().toString();
            sendMessage(message);
        }
    }
});

Wenn ich diese Ausklammer funktioniert dass Programm, wenn ich diese Stelle nicht Auskommentiere gibt es zwar keinen Error in Android Studio, aber die App stürzt auf dem Handy beim öffnen ab.

Hier ist noch der Fehlercode den ich vom debuggen bekommen habe, allerdings kann ich nichts damit anfangen.

02-29 23:51:11.720 21152-21152/? E/ActivityThread: Activity com.example.android.bluetoothchat.DeviceListActivity has leaked IntentReceiver android.view.ViewRootImpl$1@410b9b88 that was originally registered here. Are you missing a call to unregisterReceiver()?
android.app.IntentReceiverLeaked: Activity com.example.android.bluetoothchat.DeviceListActivity has leaked IntentReceiver android.view.ViewRootImpl$1@410b9b88 that was originally registered here. Are you missing a call to unregisterReceiver()?
at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:763)
at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:567)
at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1043)
at android.app.ContextImpl.registerReceiver(ContextImpl.java:1030)
at android.app.ContextImpl.registerReceiver(ContextImpl.java:1024)
at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:341)
at android.view.ViewRootImpl.<init>(ViewRootImpl.java:391)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:267)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:215)
at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:140)
at android.view.Window$LocalWindowManager.addView(Window.java:537)
at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:2507)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1986)
at android.app.ActivityThread.access$600(ActivityThread.java:123)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4424)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)

Ich hoffe auf hilfe grüße Sebo
 
Zuletzt bearbeitet von einem Moderator:

Joose

Top Contributor
Wie bist du auf die Idee gekommen, dass es sich um beim Hinzufügen des Listeners um die Fehlerquelle handelt? Laut StackTrace weißt gar nichts auf diesen Code hin.

Die Fehlermessage an sich ist ja eindeutig: Android erwartet das die Receiver registriert sind ;)
Eine mögliche Fehlerbehandlung dazu gäbe es hier: http://stackoverflow.com/questions/...-are-you-missing-a-call-to-unregisterreceiver
Für mich hat eben diese Fehlermeldung wenig bis gar nicht mit dem von der geposteten Codestück zu tun :/

Anmerkung: Code bitte immer in Code-Tags packen
[java] .. dein code .. [/java]
 

SeboSapienz

Mitglied
Danke erstmal für deinen Kommentar.
Ich denke dass mein obiger ausschnitt die fehlerquelle ist, da die app funktioniert wenn ich diesen entfehrne.
Aber trotzdem danke für deinen Beitrag ich werde es ausprobieren
 

SeboSapienz

Mitglied
ich habe in meinem Programm nachgeguckt und die receiver sind declariert:
Java:
..
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();

        // When discovery finds a device
        if (BluetoothDevice.ACTION_FOUND.equals(action)) {
            // Get the BluetoothDevice object from the Intent
            BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
            // If it's already paired, skip it, because it's been listed already
            if (device.getBondState() != BluetoothDevice.BOND_BONDED) {
                mNewDevicesArrayAdapter.add(device.getName() + "\n" + device.getAddress());
            }
            // When discovery is finished, change the Activity title
        } else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) {
            setProgressBarIndeterminateVisibility(false);
            setTitle(R.string.select_device);
            if (mNewDevicesArrayAdapter.getCount() == 0) {
                String noDevices = getResources().getText(R.string.none_found).toString();
                mNewDevicesArrayAdapter.add(noDevices);
            }
        }
    }
};..

und werden auch registriert:
Java:
..
// Register for broadcasts when a device is discovered
IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
this.registerReceiver(mReceiver, filter);

// Register for broadcasts when discovery has finished
filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
this.registerReceiver(mReceiver, filter);..

hoffe dass du mir helfen kannst
 

SeboSapienz

Mitglied
hab hier noch was gefunden:
Java:
..
protected void onDestroy() {
    super.onDestroy();

    // Make sure we're not doing discovery anymore
    if (mBtAdapter != null) {
        mBtAdapter.cancelDiscovery();
    }

    // Unregister broadcast listeners
    this.unregisterReceiver(mReceiver);
}..

vieleicht liegt der fehler darin, dass das Programm nicht diese Methode durchläuft.
Aber müsste das Programm nicht trotzdem funktionieren?
 
Ähnliche Java Themen
  Titel Forum Antworten Datum
M Repository bei Room-Database in Android Studio (Java) Android & Cross-Platform Mobile Apps 2
W In Android Studio Integer an andere activities übergeben Android & Cross-Platform Mobile Apps 2
wladp Android Studio Room Database Android & Cross-Platform Mobile Apps 1
T Android Studio: Einen Button in einer For Schleife verwenden Android & Cross-Platform Mobile Apps 2
K BLE Komunikation mit Android studio und esp32 Android & Cross-Platform Mobile Apps 5
M Paper DB wird in Android Studio nicht erkannt Android & Cross-Platform Mobile Apps 7
lolcore Android Studio -Download Documentation for Android SDK Android & Cross-Platform Mobile Apps 0
W Problem mit Android Studio Android & Cross-Platform Mobile Apps 0
OSchriever Auf onClick-Listener reagieren und Parameter übergeben (Android Studio) Android & Cross-Platform Mobile Apps 4
W Variable überschreiben (Android Studio) Android & Cross-Platform Mobile Apps 2
ruutaiokwu Android Warum muss man bei Android Studio immer 2x auf "Run" klicken damit die App auf dem Gerät startet Android & Cross-Platform Mobile Apps 8
ruutaiokwu Wie fügt man bei Android Studio .jar-Libraries zu einem Android-Java-Projekt hinzu? Android & Cross-Platform Mobile Apps 33
M Komponenten positionieren in Android Studio 3.6.3 Android & Cross-Platform Mobile Apps 1
M Android Studio - Property-Fenster einblenden Android & Cross-Platform Mobile Apps 1
M Android Studio - App auf dem Smartphone testen Android & Cross-Platform Mobile Apps 7
M Android Studio - Configuration fehlt Android & Cross-Platform Mobile Apps 20
M Unsupported class file major version 57 - Fehlermeldung bei Android Studio Android & Cross-Platform Mobile Apps 27
ruutaiokwu Android Studio (SDK) ANDROID_SDK_ROOT-Variable? Android & Cross-Platform Mobile Apps 5
J Android Studio macht seltsame Sachen Android & Cross-Platform Mobile Apps 2
J Android 9.1 aber android Studio findet API22 Android & Cross-Platform Mobile Apps 0
Dimax Web-Seite in native app convertieren mit Android Studio Android & Cross-Platform Mobile Apps 8
A Android Studio: while-Schleife beginnt nicht Android & Cross-Platform Mobile Apps 5
lolcore android studio: fehler bei laden des emulators Android & Cross-Platform Mobile Apps 10
A Android-Studio: 2. Layout nach kurzer Zeit aufzeigen Android & Cross-Platform Mobile Apps 2
A jpg wird im Android Studio nicht akzeptiert Android & Cross-Platform Mobile Apps 3
J Android Studio - ArrayList - Selected Item ermitteln Android & Cross-Platform Mobile Apps 13
A Android Studio: ImageView verpixelt Android & Cross-Platform Mobile Apps 2
J intend Service im Android Studio Android & Cross-Platform Mobile Apps 4
T Fehler Android Studio: java.net.MalformedURLException: no protocol: http%3A%2F%2Fwww.mal ..... Android & Cross-Platform Mobile Apps 2
Arif Android Android Studio: Fehler beim Einbinden fremder Bibliothek? Android & Cross-Platform Mobile Apps 2
A Android Studio - App mit Nearby Android & Cross-Platform Mobile Apps 1
Jackii Android Android Studio Error im Testlauf ohne zu programmieren Android & Cross-Platform Mobile Apps 9
B Android Probleme mit Android Studio Android & Cross-Platform Mobile Apps 6
E Wie erhalte ich Zugriff auf das Microfon? (Android Studio) Android & Cross-Platform Mobile Apps 9
L Android Android Studio - Exportierte APK funktioniert nicht Android & Cross-Platform Mobile Apps 6
A Beginnen mit Serverkommunikatsion in Android Studio Android & Cross-Platform Mobile Apps 6
E Android Studio Android & Cross-Platform Mobile Apps 15
L Android Android Studio Setup killt Explorer Android & Cross-Platform Mobile Apps 3
J Variable in strings.xml (Android Studio) Android & Cross-Platform Mobile Apps 0
B Android Android Studio lässt PC abstürzen Android & Cross-Platform Mobile Apps 3
Light Lux Fehlermeldung unter Android Studio Android & Cross-Platform Mobile Apps 1
A Android Android Studio Emulator Problem Android & Cross-Platform Mobile Apps 1
Maresuke Android Android Studio & Bitbucket Android & Cross-Platform Mobile Apps 0
S Software-Tastatur des Android-Studio-Emulators öffnen? Android & Cross-Platform Mobile Apps 0
S Android Studio Emulator falsch eingestellt? Android & Cross-Platform Mobile Apps 1
N Blackscreen bei while-Schleife? (Android-Studio) Android & Cross-Platform Mobile Apps 2
S Android Studio MySql Daten in Listview mit sub Item Android & Cross-Platform Mobile Apps 11
S Android studio, SSH an Raspberry Android & Cross-Platform Mobile Apps 14
H Android Android Studio mit NDK ünterstützung, wann? Android & Cross-Platform Mobile Apps 1
T Android MSSQL Verbindung herstellen - Android Studio Android & Cross-Platform Mobile Apps 2
J Benachrichtigung Freigabe ab Android 14 Android & Cross-Platform Mobile Apps 1
J Android Benachrichtigung zum Zeitpunkt ers Android & Cross-Platform Mobile Apps 15
J Das Beispiel von Android erzeugt Fehler Android & Cross-Platform Mobile Apps 8
J Zeitdifferenzen unter Android 7 (API < 26) berechnen Android & Cross-Platform Mobile Apps 4
W Netzwerk Verbindungen Java Android Android & Cross-Platform Mobile Apps 107
Z Android IntelliJ Android & Cross-Platform Mobile Apps 2
Android App auf das eigene Handy bekommen Android & Cross-Platform Mobile Apps 3
Alex IV Android App erstellen Android & Cross-Platform Mobile Apps 3
OnDemand CrossPlatform Kotlin iOs/Android Datenverbrauch Android & Cross-Platform Mobile Apps 2
N "Schöne" Datatable in Android und setzen von Parametern von Textview im Code Android & Cross-Platform Mobile Apps 5
N Android game programmieren Android & Cross-Platform Mobile Apps 5
G Android UDP Kommunikation Android & Cross-Platform Mobile Apps 1
J Android zugrif auf Thread nach Handy drehen. Android & Cross-Platform Mobile Apps 10
T Android Android Augmented Faces in Java. Neue Landmarks erstellen Android & Cross-Platform Mobile Apps 1
K Android Android In-App-Purchase lädt nicht Android & Cross-Platform Mobile Apps 0
Besset Android http request an interne ip adresse funktioniert nicht Android & Cross-Platform Mobile Apps 8
J Is Android Development Head First Outdated? Android & Cross-Platform Mobile Apps 3
J Android Android Datenbankverbindung zum Raspberry Pi Android & Cross-Platform Mobile Apps 1
S Sinnvollste weg eine SQLite DB mit Android auslesen Android & Cross-Platform Mobile Apps 7
W App Abo Android Android & Cross-Platform Mobile Apps 10
OSchriever Android Android MediaPlayer bei Anruf stoppen/pausieren Android & Cross-Platform Mobile Apps 2
W removeNetwork Android App mit Spendenaktion fürs Tierheim! Android & Cross-Platform Mobile Apps 1
T Android R.string.test+i Problem Android & Cross-Platform Mobile Apps 2
P undefinierbarer Fehler Android Android & Cross-Platform Mobile Apps 8
T Android ArrayList sortieren mit 2 Werten ohne thencomparing , Wie? Android & Cross-Platform Mobile Apps 10
ruutaiokwu Android Selbst entwickelter SMTP-Client läuft auf PC, nicht aber auf Android Android & Cross-Platform Mobile Apps 9
ruutaiokwu Android Wo das 'android.useAndroidX' property hinzufügen? Android & Cross-Platform Mobile Apps 8
ruutaiokwu Android In einem Android-“Spinner”-Element GLEICHZEITIG Bild (links) UND Text (rechts) anzeigen Android & Cross-Platform Mobile Apps 0
P Login und Registrierung Android Anzeige Android & Cross-Platform Mobile Apps 7
S Von JavaFx zu Android Android & Cross-Platform Mobile Apps 12
K Android to Pi | Websocket Problem Android & Cross-Platform Mobile Apps 3
M Barrierefreie Appentwicklung für Android - Suche Codebeispiele Android & Cross-Platform Mobile Apps 8
M Wo kann ich das Android SDK herunterladen / wie kann ich es installieren Android & Cross-Platform Mobile Apps 3
O Web API in Android (JAVA) einbinden Android & Cross-Platform Mobile Apps 3
J Android App - Browser öffnen und Text eingeben/Button click auslösen Android & Cross-Platform Mobile Apps 10
T Android SDK-Manager startet nicht in Eclipse Android & Cross-Platform Mobile Apps 5
T Bringen mir die Java-Basics irgendetwas für die Android-Programmierung Android & Cross-Platform Mobile Apps 4
J Was soll das bedeuten ? does not require android.permission.BIND_JOB_SERVICE permission Android & Cross-Platform Mobile Apps 7
L Android Android Development eventuell mit Flutter Android & Cross-Platform Mobile Apps 1
S Android Layout - welchen Typ? Android & Cross-Platform Mobile Apps 3
L Android Android Contacts DB auslesen Android & Cross-Platform Mobile Apps 1
L Android content URI Datei einlesen Android & Cross-Platform Mobile Apps 9
N Android Game Background Service Android & Cross-Platform Mobile Apps 11
Excess Android Service läuft nicht in Sandby weiter Android & Cross-Platform Mobile Apps 2
B Android Projekt für Android und IOS erstellen? Android & Cross-Platform Mobile Apps 5
J App funktioniert auf Android 5, auf 6 nicht Android & Cross-Platform Mobile Apps 2
J Android Snake Android & Cross-Platform Mobile Apps 15
J Android TaschenRechner Android & Cross-Platform Mobile Apps 22
I Das Problem mit der Tastatur... android:windowSoftInputMode="adjustPan" Android & Cross-Platform Mobile Apps 1
C Android Programmierung speziell oder einfach Java Buch kaufen? Android & Cross-Platform Mobile Apps 3

Ähnliche Java Themen

Neue Themen


Oben