android studio url aus einer textview

  • Antworten:23
pschmitz
  • Forum-Beiträge: 13

19.03.2018, 22:46:52 via Website

Hallo,
sorry habe erst vor kurzen angefangen Apps zu programmieren. Ich möchte, das die Url aus einer Textview (txt_ipAdresseLichteg) ausgelesen wird.
Zur Zeit steht die ip Adresse fest in der MailActivity.

String url5 = "(meine_ip_Adresse/)"; //NodeMCU ESP-ACA3E6

Wie kann ich diese aus der Textview auslesen? Kamm mir einer da weiter helfen? Danke

Die habe ich schon probiert, es klappt aber nicht.
String url5 = txt_ipAdresseLichteg .getText().toString();
String url5 = (txt_ipAdresseLichteg.toString());

Kommentieren
Pascal P.
  • Admin
  • Forum-Beiträge: 11.286

19.03.2018, 23:12:49 via Website

Hallo pschmitz,
herzlich wilkommen hier im Forum :)



dafür brauchst du keine TextView im Layout sondern ein EditText.
Da kannst du deine Url dann reintippen und den String mit

myEditText.getText().toString();

auslesen.
Ich glaube du hast ausversehen nur ein TextView und keine EditText benutzt.

LG Pascal //It's not a bug, it's a feature. :) ;)

Hilfreich?
pschmitz
Kommentieren
pschmitz
  • Forum-Beiträge: 13

20.03.2018, 00:11:35 via Website

Hallo,
ich habe eine Activitylan, da speichere ich die ip Adressen in einer Textdatei. In der MailActivity lese ich die Textdatei aus und schreibe diese in einer Textview, damit ich sehe welche ip ich vergeben habe. Ich habe insgesamt 15 IP Adressen für die NodeMCU ESP-ACA3E6
Mit freundlichen Grüßen
p.schmitz

Hilfreich?
Kommentieren
Pascal P.
  • Admin
  • Forum-Beiträge: 11.286

20.03.2018, 10:50:17 via App

wenn der Wert schon in der TextView steht, kannst du den da auch wieder auslesen, aber eigentlich nimmt man dafür die Datenquelle und keine View Fields.
Bist du dir sicher, dass es nicht geht?
Hast du mal den Debugger drüber laufen lassen und dir die Werte angeschaut?

LG Pascal //It's not a bug, it's a feature. :) ;)

Hilfreich?
Kommentieren
pschmitz
  • Forum-Beiträge: 13

20.03.2018, 18:14:03 via Website

Hallo der Wert wird mir richtig angezeigt. wenn ich die ip ändere wird das auch richtig angezeigt.
mit String url5 = "(http)meineIP"; funktioniert die App,
wenn ich die in String url5 = txt_ipAdresseLichteg.getText().toString(); schreibe.
Stürtz die app ab. :(

hiermit lese ich die serverip3.txt aus meinem Handy aus:

// IP Adresse laden
File dir = new File (path);
dir.mkdirs();

    // Iptext laden
    {
        File file  = new File(path +  "/serverip3.txt");
        String [] loadText = Load(file);
        String finalString = "";
        for (int i = 0; i < loadText.length; i++)
        {
            finalString += loadText[i] + System.getProperty("line.separator");
        }
        txt_ipAdresseLichteg.setText(finalString);
        editText_ip.setText(finalString);

    }
    //  IP Adresse laden

Das ist mein onClickListener:
btn_Licht1eg.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//String url5_rl = url5 + "Rel1"; // Damit funktioniert es!

       // String url5_rl = (txt_ipAdresseLichteg + "Rel1") ;
       // String url5_rl = (txt_ipAdresseLichteg + "Rel1");
       //String url5_rl = txt_ipAdresseLichteg.toString() + "Rel1";
        //String url5_rl = url5 + "Rel1";
        //textView_2.setText(txt_ipAdresseLichteg + "Rel1");
        SelectTask5 task = new SelectTask5(url5_rl);
        task.execute();
        updateStatus5();

    }

Sorry kann die ganze IP nicht schreiben:
Um Spam in unserem Forum zu vermeiden, können neue Mitglieder vorerst keine Links auf externe Webseiten veröffentlichen.

Hilfreich?
Kommentieren
Pascal P.
  • Admin
  • Forum-Beiträge: 11.286

20.03.2018, 19:17:09 via Website

Die IP brauch ich auch nicht,
aber den roten Log aus Logcat wenn die App abstürtzt wäre hilfreich.
Wo deklarierst du die TextView und machst en findViewById?

LG Pascal //It's not a bug, it's a feature. :) ;)

Hilfreich?
Kommentieren
pschmitz
  • Forum-Beiträge: 13

20.03.2018, 19:58:33 via Website

Das ist mein Script:

import android.content.Context;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.support.v7.app.AppCompatActivity;
import android.text.method.LinkMovementMethod;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.TextView;
import org.json.JSONException;
import org.json.JSONObject;
import org.w3c.dom.Text;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;

public class ActivityLichtEG extends AppCompatActivity implements OnDataSendToActivity5 {

Button btn_Licht1eg;
Button btn_Licht2eg;
Button btn_Licht3eg;
Button btn_Licht4eg;
Button btn_Licht5eg;
Button btn_Licht6eg;
Button btn_Licht7eg;
Button btn_Licht8eg;

Button btn_EGmenueLicht;
Button btn_LichtEGallean;
Button btn_LichtEGalleaus;
Button btn_LANverbinden;

ImageView ImageView_Hintergrungeg;        // Hintergrung
TextView txt_verbinugenLichteg;   // IP Adresse
TextView txt_ipAdresseLichteg;  // Stauts
TextView textView_2;

public EditText editText_ip;


//  IP Adresse laden
public String path = Environment.getExternalStorageDirectory().getAbsolutePath()+ "/RLS";



String url5 = "(meineip/)"; //Define your NodeMCU ESP-ACA3E6
//String url5 = editText_ip.getText().toString();

////String url5 =  editText_ip.getText().toString();
// String url5 = txt_ipAdresseLichteg .getText().toString();
//String url5 =  (txt_ipAdresseLichteg.toString());

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_licht_eg);

    btn_Licht1eg = (Button) findViewById(R.id.btnLicht1eg);
    btn_Licht2eg = (Button) findViewById(R.id.btnLicht2eg);
    btn_Licht3eg = (Button) findViewById(R.id.btnLicht3eg);
    btn_Licht4eg = (Button) findViewById(R.id.btnLicht4eg);
    btn_Licht5eg = (Button) findViewById(R.id.btnLicht5eg);
    btn_Licht6eg = (Button) findViewById(R.id.btnLicht6eg);
    btn_Licht7eg = (Button) findViewById(R.id.btnLicht7eg);
    btn_Licht8eg = (Button) findViewById(R.id.btnLicht8eg);
    btn_EGmenueLicht = (Button) findViewById(R.id.btnEGmenueLicht);
    btn_LichtEGallean = (Button) findViewById(R.id.btnLichtEGallean);
    btn_LichtEGalleaus = (Button) findViewById(R.id.btnLichtEGalleaus);
    btn_LANverbinden = (Button) findViewById(R.id.btnLanspeichern);
    ImageView_Hintergrungeg = (ImageView) findViewById(R.id.ImageViewHintergrungeg);
    txt_verbinugenLichteg = (TextView) findViewById(R.id.txtverbinugenLichteg);
    txt_ipAdresseLichteg = (TextView) findViewById(R.id.txtipAdresseLichteg);
    editText_ip = (EditText) findViewById(R.id.editTextip);


    //TextView t2 = (TextView) findViewById(R.id.textView2);
    //t2.setMovementMethod(LinkMovementMethod.getInstance());

    //  IP Adresse laden
    File dir = new File (path);
    dir.mkdirs();

    // Iptext laden
    {
        File file  = new File(path +  "/serverip3.txt");
        String [] loadText = Load(file);
        String finalString = "";
        for (int i = 0; i < loadText.length; i++)
        {
            finalString += loadText[i] + System.getProperty("line.separator");
        }
        txt_ipAdresseLichteg.setText(finalString);
        editText_ip.setText(finalString);

    }
    //  IP Adresse laden

     final Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
    @Override
    public void run() {
        if (isNetworkAvailable5()) {
            ImageView_Hintergrungeg.setImageResource(R.drawable.background_on);
            txt_verbinugenLichteg.setText("Verbunden mit der IP");

        } else {
            ImageView_Hintergrungeg.setImageResource(R.drawable.background);
            txt_verbinugenLichteg.setText("Konnte keine Verbindung zum Server herstellen");
        }
        updateStatus5();
        handler.postDelayed(this, 2000);
    }
}, 5000);  //the time is in miliseconds


    btn_Licht1eg.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        //String url5_rl = url5 + "Rel1"; // ezt Tür
       String url5_rl = url5 + "Rel1";


        //String url5_rl = url5 + "Rel1";
       // String url5_rl = (txt_ipAdresseLichteg + "Rel1") ;
       // String url5_rl = (txt_ipAdresseLichteg + "Rel1");
       //String url5_rl = txt_ipAdresseLichteg.toString() + "Rel1";
        //String url5_rl = url5 + "Rel1";
        //textView_2.setText(txt_ipAdresseLichteg + "Rel1");

        SelectTask5 task = new SelectTask5(url5_rl);
        task.execute();
        updateStatus5();

    }
});
    btn_Licht2eg.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        String url5_rl = url5 + "Rel2"; // ST1
        SelectTask5 task = new SelectTask5(url5_rl);
        task.execute();
        updateStatus5();
    }
});
    btn_Licht3eg.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        String url5_rl = url5 +"Rel3"; // ST1
        SelectTask5 task = new SelectTask5(url5_rl);
        task.execute();
        updateStatus5();
    }
});
    btn_Licht4eg.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        String url5_rl = url5 +"Rel4";  // ST1
        SelectTask5 task = new SelectTask5(url5_rl);
        task.execute();
        updateStatus5();
    }
});
    btn_Licht5eg.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        String url5_rl = url5 + "Rel5";
        SelectTask5 task = new SelectTask5(url5_rl);
        task.execute();
        updateStatus5();
    }
});
    btn_Licht6eg.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        String url5_rl = url5 + "Rel6";
        SelectTask5 task = new SelectTask5(url5_rl);
        task.execute();
        updateStatus5();
    }
});
    btn_Licht7eg.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        String url5_rl = url5 +"Rel7";
        SelectTask5 task = new SelectTask5(url5_rl);
        task.execute();
        updateStatus5();
    }
});
    btn_Licht8eg.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        String url5_rl = url5 + "Rel8";
        SelectTask5 task = new SelectTask5(url5_rl);
        task.execute();
        updateStatus5();
    }

});
    btn_LichtEGallean.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        String url5_rl = url5 + "allean";
        SelectTask5 task = new SelectTask5(url5_rl);
        task.execute();
        updateStatus5();
    }

    });
    btn_LichtEGalleaus.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            String url5_rl = url5 + "alleaus";
            SelectTask5 task = new SelectTask5(url5_rl);
            task.execute();
            updateStatus5();


    }

    });
    btn_LANverbinden.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            Intent intent = new Intent(ActivityLichtEG.this, ActivityLAN.class);
            startActivity(intent);
            finish();

    }

}); // Menü
    btn_EGmenueLicht.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View view) {
        Intent intent = new Intent(ActivityLichtEG.this, ActivityScrolling.class);
        startActivity(intent);
        finish();
    }
});

}
// IP Adresse laden
public static String[] Load(File file)
{
FileInputStream fis = null;
try
{
fis = new FileInputStream(file);
}
catch (FileNotFoundException e){e.printStackTrace(); }
InputStreamReader isr = new InputStreamReader(fis);
BufferedReader br = new BufferedReader(isr);

    String test;
    int anzahl = 0;
    try {
        while ((test = br.readLine()) != null) {
            anzahl++;
        }
    }

    catch (IOException e) {e.printStackTrace();}
    try
    {
        fis.getChannel().position(0);
    }

    catch (IOException e) {e.printStackTrace();}
    String[] array = new String[anzahl];

    String line;
    int i = 0;
    try
    {
        while ((line = br.readLine()) != null)
        {
            array[i] = line;
            i++;
        }
    }
    catch (IOException e) {e.printStackTrace();}
    return array;

}

private boolean isNetworkAvailable5() {
    ConnectivityManager connectivityManager
            = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
    return activeNetworkInfo != null && activeNetworkInfo.isConnected();
}

@Override
public void sendData5(String str) {
    updateButtonStatus5(str);
}

private void updateStatus5() {
    String url5_rl = url5 + "status5";
    StatusTask5 task = new StatusTask5(url5_rl, this);
    task.execute();
}

//Funktion zum Aktualisieren des Tastenstatus
private void updateButtonStatus5(String jsonStrings) {
    try {
        JSONObject json = new JSONObject(jsonStrings);

        String Rel1 = json.getString("Rel1");             // btn_20  Ausgang: D5
        String Rel2 = json.getString("Rel2");             // btn_21  Ausgang: D6
        String Rel3 = json.getString("Rel3");             // btn_22  Ausgang: D7
        String Rel4 = json.getString("Rel4");               // btn_23  Ausgang: D8
        String Rel5 = json.getString("Rel5");             // btn_20  Ausgang: D5
        String Rel6 = json.getString("Rel6");             // btn_20  Ausgang: D5
        String Rel7 = json.getString("Rel7");             // btn_20  Ausgang: D5
        String Rel8 = json.getString("Rel8");             // btn_20  Ausgang: D5
        String allean = json.getString("allean");             // btn_20  Ausgang: D5
        String alleaus = json.getString("alleaus");             // btn_20  Ausgang: D5

        if (Rel1.equals("1")) {
            btn_Licht1eg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.power_on);
        } else {
            btn_Licht1eg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.power_off);
        }
        if (Rel2.equals("1")) {
            btn_Licht2eg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.power_on);
        } else {
            btn_Licht2eg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.power_off);
        }
        if (Rel3.equals("1")) {
            btn_Licht3eg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.power_on);
        } else {
            btn_Licht3eg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.power_off);
        }
        if (Rel4.equals("1")) {
            btn_Licht4eg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.power_on);
        } else {
            btn_Licht4eg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.power_off);
        }
        if (Rel5.equals("1")) {
            btn_Licht5eg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.power_on);
        } else {
            btn_Licht5eg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.power_off);
        }
        if (Rel6.equals("1")) {
            btn_Licht6eg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.power_on);
        } else {
            btn_Licht6eg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.power_off);
        }
        if (Rel7.equals("1")) {
            btn_Licht7eg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.power_on);
        } else {
            btn_Licht7eg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.power_off);
        }
        if (Rel8.equals("1")) {
            btn_Licht8eg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.power_on);
        } else {
            btn_Licht8eg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.power_off);
        }
        if (allean.equals("1")) {
            btn_Licht1eg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.power_on);
            btn_Licht2eg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.power_on);
            btn_Licht3eg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.power_on);
            btn_Licht4eg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.power_on);
            btn_Licht5eg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.power_on);
            btn_Licht6eg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.power_on);
            btn_Licht7eg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.power_on);
            btn_Licht8eg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.power_on);
        } else {
            btn_Licht1eg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.power_off);
            btn_Licht2eg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.power_off);
            btn_Licht3eg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.power_off);
            btn_Licht4eg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.power_off);
            btn_Licht5eg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.power_off);
            btn_Licht6eg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.power_off);
            btn_Licht7eg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.power_off);
            btn_Licht8eg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.power_off);
        }
        if (alleaus.equals("1")) {
            btn_Licht1eg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.power_on);
            btn_Licht2eg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.power_on);
            btn_Licht3eg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.power_on);
        } else {
            btn_Licht1eg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.power_off);
            btn_Licht2eg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.power_off);
            btn_Licht3eg.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, R.drawable.power_off);
        }

    } catch (JSONException e) {
        e.printStackTrace();
    }

}

}

Hilfreich?
Kommentieren
Pascal P.
  • Admin
  • Forum-Beiträge: 11.286

20.03.2018, 21:08:27 via Website

Du solltest dir Helper Klassen schreiben, damit dein Code übersichtlicher wird ;)

Warum musst du die IP aus dem Feld auslesen?

Warum nicht so?
(Pseudocode)

String myIp;
myIp = readFromFile(myFileName);
myTextField.setText(myIp)
myDevice.connect(myIp);

Wenn du es so machst, nimmst du direkt den aus dem File gelesenen String als IP und du musst das nicht aus dem Textfeld tun.

Aber das beantwortet meine Frage nach dem Log immer noch nicht...

LG Pascal //It's not a bug, it's a feature. :) ;)

Hilfreich?
pschmitz
Kommentieren
pschmitz
  • Forum-Beiträge: 13

20.03.2018, 21:56:28 via Website

Hallo Pascal,
ist meine erste App und d.h noch Anfänger.
ich denke, das mit Zeit und Erfahrung werde ich so was besser schreiben.
Ich lasse mir in der Activity die IP anzeigen, damit ich sehe an welche IP Adresse die Befehle gesendet werden und ich kann, über den Webbrowser (ipdaresse) auch die Ausgänge Ein/Aus schalten.
Logfile steht nicht nennenswertes:
20.03.2018
21:53 Executing tasks: [:app:assembleDebug]
21:53 Gradle build finished in 12s 533ms

Hilfreich?
Kommentieren
Pascal P.
  • Admin
  • Forum-Beiträge: 11.286

20.03.2018, 21:59:31 via App

Du brauchst den Log während die App abstürzt.
Sonst bringt das nichts.

LG Pascal //It's not a bug, it's a feature. :) ;)

Hilfreich?
Kommentieren
pschmitz
  • Forum-Beiträge: 13

20.03.2018, 22:01:32 via Website

ja das habe ich.
Sobald ich die String url = “meine ip“ ändere stürzt die App ab, keine Fehler im Log

— geändert am 20.03.2018, 22:03:48

Hilfreich?
Kommentieren
Pascal P.
  • Admin
  • Forum-Beiträge: 11.286

20.03.2018, 22:03:33 via App

In AndroidStudio das Fenster LogCat und da den roten Text. Muss ne Exception sein

LG Pascal //It's not a bug, it's a feature. :) ;)

Hilfreich?
pschmitz
Kommentieren
pschmitz
  • Forum-Beiträge: 13

20.03.2018, 22:15:28 via Website

Ich glaube, das ist bei mir deaktiviert, ich habe nur Event Log.
Ich schau mal nach. Sorry

                                                                        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2809)
                                                                        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2988) 
                                                                        at android.app.ActivityThread.-wrap14(ActivityThread.java) 
                                                                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1631) 
                                                                        at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                        at android.os.Looper.loop(Looper.java:154) 
                                                                        at android.app.ActivityThread.main(ActivityThread.java:6682) 
                                                                        at java.lang.reflect.Method.invoke(Native Method) 
                                                                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520) 
                                                                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410) 

Ich hoffe du meinst das?

— geändert am 20.03.2018, 22:20:06

Hilfreich?
Kommentieren
Pascal P.
  • Admin
  • Forum-Beiträge: 11.286

20.03.2018, 22:42:12 via App

Jup aber das ist nicht vollständig...

LG Pascal //It's not a bug, it's a feature. :) ;)

Hilfreich?
Kommentieren
pschmitz
  • Forum-Beiträge: 13

20.03.2018, 22:43:47 via Website

Ja ich weis, ich hab nur den den Teil genommen der Rot war.

Hilfreich?
Kommentieren
Pascal P.
  • Admin
  • Forum-Beiträge: 11.286

21.03.2018, 00:06:52 via App

Das muss aber schon vorher anfangen

LG Pascal //It's not a bug, it's a feature. :) ;)

Hilfreich?
Kommentieren
pschmitz
  • Forum-Beiträge: 13

21.03.2018, 10:51:33 via Website

So ich hab das Ganze mal gemacht und hoffe das du damit was anfangen kannst?

Logcat:
03-21 10:48:16.080 21909-21909/? E/Zygote: v2
03-21 10:48:16.080 21909-21909/? I/libpersona: KNOX_SDCARD checking this for 10227
03-21 10:48:16.080 21909-21909/? I/libpersona: KNOX_SDCARD not a persona
03-21 10:48:16.081 21909-21909/? E/Zygote: accessInfo : 0
03-21 10:48:16.082 21909-21909/? W/SELinux: SELinux selinux_android_compute_policy_index : Policy Index[2], Con:u:r:zygote:s0 RAM:SEPF_SECMOBILE_7.0_0005, [-1 -1 -4 -1 0 1]
03-21 10:48:16.083 21909-21909/? I/SELinux: SELinux: seapp_context_lookup: seinfo=untrusted, level=s0:c512,c768, pkgname=com.pombingsoft.myroom
03-21 10:48:16.088 21909-21909/? I/art: Late-enabling -Xcheck:jni
03-21 10:48:16.105 21909-21909/? D/TimaKeyStoreProvider: TimaKeyStore is not enabled: cannot add TimaSignature Service and generateKeyPair Service
03-21 10:48:16.111 21909-21916/? I/art: Debugger is no longer active
03-21 10:48:16.111 21909-21916/? I/art: Starting a blocking GC Instrumentation
03-21 10:48:16.131 21909-21909/? W/System: ClassLoader referenced unknown path: /data/app/com.pombingsoft.myroom-1/lib/arm64
03-21 10:48:16.165 21909-21909/? W/art: Before Android 4.1, method android.graphics.PorterDuffColorFilter android.support.graphics.drawable.VectorDrawableCompat.updateTintFilter(android.graphics.PorterDuffColorFilter, android.content.res.ColorStateList, android.graphics.PorterDuff$Mode) would have incorrectly overridden the package-private method in android.graphics.drawable.Drawable
03-21 10:48:16.235 21909-21909/? D/ViewRootImpl@7232949[LoginActivity]: ThreadedRenderer.create() translucent=false
03-21 10:48:16.237 21909-21909/? D/InputTransport: Input channel constructed: fd=57
03-21 10:48:16.238 21909-21909/? D/ViewRootImpl@7232949[LoginActivity]: setView = DecorView@803024e[LoginActivity] touchMode=true
03-21 10:48:16.242 21909-21909/? D/ViewRootImpl@7232949[LoginActivity]: dispatchAttachedToWindow
03-21 10:48:16.255 21909-21909/? D/ViewRootImpl@7232949[LoginActivity]: Relayout returned: oldFrame=[0,0][0,0] newFrame=[0,0][1440,2560] result=0x27 surface={isValid=true 524749743616} surfaceGenerationChanged=true
03-21 10:48:16.255 21909-21909/? D/ViewRootImpl@7232949[LoginActivity]: mHardwareRenderer.initialize() mSurface={isValid=true 524749743616} hwInitialized=true
03-21 10:48:16.268 21909-21909/? D/ViewRootImpl@7232949[LoginActivity]: MSG_RESIZED_REPORT: ci=Rect(0, 96 - 0, 0) vi=Rect(0, 96 - 0, 0) or=1
03-21 10:48:16.275 21909-21927/? D/libEGL: loaded /vendor/lib64/egl/libGLES_mali.so
03-21 10:48:16.301 21909-21927/? I/OpenGLRenderer: Initialized EGL, version 1.4
03-21 10:48:16.301 21909-21927/? D/OpenGLRenderer: Swap behavior 1
03-21 10:48:16.306 21909-21927/? D/mali_winsys: EGLint new_window_surface(egl_winsys_display*, void*, EGLSurface, EGLConfig, egl_winsys_surface**, egl_color_buffer_format*, EGLBoolean) returns 0x3000, [1440x2560]-format:1
03-21 10:48:16.338 21909-21909/? D/ViewRootImpl@7232949[LoginActivity]: MSG_WINDOW_FOCUS_CHANGED 1
03-21 10:48:16.338 21909-21909/? D/ViewRootImpl@7232949[LoginActivity]: mHardwareRenderer.initializeIfNeeded()#2 mSurface={isValid=true 524749743616}
03-21 10:48:16.341 21909-21909/? D/SEM_CLIP_SemClipboardManager: isCocktailBarDisplayed : false
03-21 10:48:16.343 21909-21909/? D/SEM_CLIP_SemClipboardManager: isCocktailBarDisplayed : false
03-21 10:48:16.344 21909-21909/? V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@e418b61 nm : com.pombingsoft.myroom ic=com.android.internal.widget.EditableInputConnection@8661686
03-21 10:48:16.345 21909-21909/? I/InputMethodManager: [IMM] startInputInner - mService.startInputOrWindowGainedFocus
03-21 10:48:16.347 21909-21922/? D/InputTransport: Input channel constructed: fd=68
03-21 10:48:16.349 21909-21909/? V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@ff89b47 nm : com.pombingsoft.myroom ic=com.android.internal.widget.EditableInputConnection@c13ef74
03-21 10:48:17.536 21909-21909/com.pombingsoft.myroom D/ViewRootImpl@7232949[LoginActivity]: ViewPostImeInputStage processPointer 0
03-21 10:48:17.537 21909-21909/com.pombingsoft.myroom W/System: ClassLoader referenced unknown path: /system/framework/QPerformance.jar
03-21 10:48:17.538 21909-21909/com.pombingsoft.myroom E/BoostFramework: BoostFramework() : Exception_1 = java.lang.ClassNotFoundException: Didn't find class "com.qualcomm.qti.Performance" on path: DexPathList[[],nativeLibraryDirectories=[/system/lib64, /vendor/lib64]]
03-21 10:48:17.538 21909-21909/com.pombingsoft.myroom V/BoostFramework: BoostFramework() : mPerf = null
03-21 10:48:17.599 21909-21909/com.pombingsoft.myroom D/ViewRootImpl@7232949[LoginActivity]: ViewPostImeInputStage processPointer 1
03-21 10:48:17.655 21909-21909/com.pombingsoft.myroom D/ViewRootImpl@99a4e3[Toast]: ThreadedRenderer.create() translucent=true
03-21 10:48:17.658 21909-21909/com.pombingsoft.myroom D/InputTransport: Input channel constructed: fd=73
03-21 10:48:17.659 21909-21909/com.pombingsoft.myroom D/ViewRootImpl@99a4e3[Toast]: setView = android.widget.LinearLayout{c3a8ee0 V.E...... ......I. 0,0-0,0} touchMode=true
03-21 10:48:17.660 21909-21909/com.pombingsoft.myroom D/ViewRootImpl@7232949[LoginActivity]: MSG_WINDOW_FOCUS_CHANGED 0
03-21 10:48:17.660 21909-21909/com.pombingsoft.myroom D/SEM_CLIP_SemClipboardManager: isCocktailBarDisplayed : false
03-21 10:48:17.661 21909-21909/com.pombingsoft.myroom D/SEM_CLIP_SemClipboardManager: isCocktailBarDisplayed : false
03-21 10:48:17.671 21909-21909/com.pombingsoft.myroom D/ViewRootImpl@99a4e3[Toast]: dispatchAttachedToWindow
03-21 10:48:17.684 21909-21909/com.pombingsoft.myroom D/ViewRootImpl@99a4e3[Toast]: Relayout returned: oldFrame=[0,0][0,0] newFrame=[222,2128][1217,2304] result=0x27 surface={isValid=true 524749750784} surfaceGenerationChanged=true
03-21 10:48:17.684 21909-21909/com.pombingsoft.myroom D/ViewRootImpl@99a4e3[Toast]: mHardwareRenderer.initialize() mSurface={isValid=true 524749750784} hwInitialized=true
03-21 10:48:17.685 21909-21927/com.pombingsoft.myroom D/mali_winsys: EGLint new_window_surface(egl_winsys_display*, void*, EGLSurface, EGLConfig, egl_winsys_surface**, egl_color_buffer_format*, EGLBoolean) returns 0x3000, [995x176]-format:1
03-21 10:48:17.735 21909-21909/com.pombingsoft.myroom D/ViewRootImpl@5b12eb[ActivityScrolling]: ThreadedRenderer.create() translucent=false
03-21 10:48:17.737 21909-21909/com.pombingsoft.myroom D/InputTransport: Input channel constructed: fd=74
03-21 10:48:17.738 21909-21909/com.pombingsoft.myroom D/ViewRootImpl@5b12eb[ActivityScrolling]: setView = DecorView@34cd848[ActivityScrolling] touchMode=true
03-21 10:48:17.739 21909-21909/com.pombingsoft.myroom D/ViewRootImpl@99a4e3[Toast]: MSG_RESIZED_REPORT: ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1
03-21 10:48:17.757 21909-21909/com.pombingsoft.myroom D/ViewRootImpl@5b12eb[ActivityScrolling]: dispatchAttachedToWindow
03-21 10:48:17.772 21909-21909/com.pombingsoft.myroom D/ViewRootImpl@5b12eb[ActivityScrolling]: Relayout returned: oldFrame=[0,0][0,0] newFrame=[0,0][1440,2560] result=0x7 surface={isValid=true 524225276928} surfaceGenerationChanged=true
03-21 10:48:17.772 21909-21909/com.pombingsoft.myroom D/ViewRootImpl@5b12eb[ActivityScrolling]: mHardwareRenderer.initialize() mSurface={isValid=true 524225276928} hwInitialized=true
03-21 10:48:17.780 21909-21927/com.pombingsoft.myroom D/mali_winsys: EGLint new_window_surface(egl_winsys_display*, void*, EGLSurface, EGLConfig, egl_winsys_surface**, egl_color_buffer_format*, EGLBoolean) returns 0x3000, [1440x2560]-format:1
03-21 10:48:17.808 21909-21909/com.pombingsoft.myroom D/ViewRootImpl@5b12eb[ActivityScrolling]: MSG_RESIZED_REPORT: ci=Rect(0, 96 - 0, 0) vi=Rect(0, 96 - 0, 0) or=1
03-21 10:48:17.808 21909-21909/com.pombingsoft.myroom D/ViewRootImpl@5b12eb[ActivityScrolling]: MSG_WINDOW_FOCUS_CHANGED 1
03-21 10:48:17.808 21909-21909/com.pombingsoft.myroom D/ViewRootImpl@5b12eb[ActivityScrolling]: mHardwareRenderer.initializeIfNeeded()#2 mSurface={isValid=true 524225276928}
03-21 10:48:17.817 21909-21909/com.pombingsoft.myroom V/InputMethodManager: Starting input: tba=android.view.inputmethod.EditorInfo@b42a990 nm : com.pombingsoft.myroom ic=null
03-21 10:48:17.817 21909-21909/com.pombingsoft.myroom I/InputMethodManager: [IMM] startInputInner - mService.startInputOrWindowGainedFocus
03-21 10:48:17.837 21909-21909/com.pombingsoft.myroom D/InputTransport: Input channel constructed: fd=83
03-21 10:48:17.837 21909-21909/com.pombingsoft.myroom D/InputTransport: Input channel destroyed: fd=68
03-21 10:48:17.849 21909-21909/com.pombingsoft.myroom W/IInputConnectionWrapper: finishComposingText on inactive InputConnection
03-21 10:48:17.853 21909-21909/com.pombingsoft.myroom D/ViewRootImpl@7232949[LoginActivity]: mHardwareRenderer.destroy()#1
03-21 10:48:17.858 21909-21909/com.pombingsoft.myroom D/ViewRootImpl@7232949[LoginActivity]: Relayout returned: oldFrame=[0,0][1440,2560] newFrame=[0,0][1440,2560] result=0x5 surface={isValid=false 0} surfaceGenerationChanged=true
03-21 10:48:19.641 21909-21909/com.pombingsoft.myroom D/ViewRootImpl@99a4e3[Toast]: mHardwareRenderer.destroy()#4
03-21 10:48:19.644 21909-21909/com.pombingsoft.myroom D/ViewRootImpl@99a4e3[Toast]: dispatchDetachedFromWindow
03-21 10:48:19.668 21909-21909/com.pombingsoft.myroom D/InputTransport: Input channel destroyed: fd=73
03-21 10:48:25.725 21909-21909/com.pombingsoft.myroom D/ViewRootImpl@5b12eb[ActivityScrolling]: ViewPostImeInputStage processPointer 0
03-21 10:48:25.822 21909-21909/com.pombingsoft.myroom D/ViewRootImpl@5b12eb[ActivityScrolling]: ViewPostImeInputStage processPointer 1
03-21 10:48:25.860 21909-21909/com.pombingsoft.myroom D/ViewRootImpl@5b12eb[ActivityScrolling]: MSG_WINDOW_FOCUS_CHANGED 0
03-21 10:48:25.877 21909-21909/com.pombingsoft.myroom D/AndroidRuntime: Shutting down VM
03-21 10:48:25.878 21909-21909/com.pombingsoft.myroom E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.pombingsoft.myroom, PID: 21909
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.pombingsoft.myroom/com.pombingsoft.myroom.ActivityLichtEG}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.CharSequence android.widget.TextView.getText()' on a null object reference
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2819)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2988)
at android.app.ActivityThread.-wrap14(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1631)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6682)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.CharSequence android.widget.TextView.getText()' on a null object reference
at com.pombingsoft.myroom.ActivityLichtEG.(ActivityLichtEG.java:53)
at java.lang.Class.newInstance(Native Method)
at android.app.Instrumentation.newActivity(Instrumentation.java:1086)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2809)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2988) 
at android.app.ActivityThread.-wrap14(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1631) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6682) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410) 

Hilfreich?
Pascal P.
Kommentieren
Pascal P.
  • Admin
  • Forum-Beiträge: 11.286

21.03.2018, 11:34:52 via App

Genau, eigentliche Fehlermeldung:

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.pombingsoft.myroom/com.pombingsoft.myroom.ActivityLichtEG}: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.CharSequence android.widget.TextView.getText()' on a null object reference 
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2819) 
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2988) 
at android.app.ActivityThread.-wrap14(ActivityThread.java) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1631) 
at android.os.Handler.dispatchMessage(Handler.java:102) 
at android.os.Looper.loop(Looper.java:154) 
at android.app.ActivityThread.main(ActivityThread.java:6682) 
at java.lang.reflect.Method.invoke(Native Method) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1520) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410) 
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.CharSequence android.widget.TextView.getText()' on a null object reference 
at com.pombingsoft.myroom.ActivityLichtEG.(ActivityLichtEG.java:53) 
at java.lang.Class.newInstance(Native Method) 
at android.app.Instrumentation.newActivity(Instrumentation.java:1086) 
at 

Deine TextView ist null d.h. sie wird nicht initialisiert oder auf dem Layout nicht gefunden.

ActivitiyLichtEg Zeile 53. Was steht da?

LG Pascal //It's not a bug, it's a feature. :) ;)

Hilfreich?
pschmitz
Kommentieren
pschmitz
  • Forum-Beiträge: 13

21.03.2018, 12:11:09 via Website

Z 53:
String url5 = txt_ipAdresseLichteg .getText().toString();
Es kann sein das String url5 vorher ab gefrag wird und das aus lesen aus der Text.datei später erfolgt:
// IP Adresse laden
File dir = new File (path);
dir.mkdirs();

    // Iptext laden
    {
        File file  = new File(path +  "/serverip3.txt");
        String [] loadText = Load(file);
        String finalString = "";
        for (int i = 0; i < loadText.length; i++)
        {
            finalString += loadText[i] + System.getProperty("line.separator");
        }
        txt_ipAdresseLichteg.setText(finalString);

        // Test mit EditText
        editText_ip.setText(finalString);
    }
Hilfreich?
Kommentieren
Pascal P.
  • Admin
  • Forum-Beiträge: 11.286

21.03.2018, 12:12:38 via App

Das darf nicht sein.
Speicher dir den finalString der IP zusätzlich ab, dann musst du es nicht auslesen. Warum auch immer du das nicht machen willst...

LG Pascal //It's not a bug, it's a feature. :) ;)

Hilfreich?
pschmitz
Kommentieren
pschmitz
  • Forum-Beiträge: 13

21.03.2018, 12:29:52 via Website

Hallo,
ich hab das mal umgestellt, werde es heute Abend ausprobieren. Danke für die Hilfestellung!

Hilfreich?
Kommentieren
pschmitz
  • Forum-Beiträge: 13

21.03.2018, 19:07:11 via Website

Hallo Pascal,
das String url5 wird abgefragt bevor die ip zur Verfügung steht und des weg stürzt die App ab.
Ich werde in der Zukunft so was in einem Try programmieren.
Vielen Dank für die Hilfestellung !!!!
Jetzt funktioniert alles.
LG

Hilfreich?
Kommentieren
Pascal P.
  • Admin
  • Forum-Beiträge: 11.286

21.03.2018, 21:49:26 via Website

das String url5 wird abgefragt bevor die ip zur Verfügung steht und des weg stürzt die App ab.
Ich werde in der Zukunft so was in einem Try programmieren.

Das ist auch nicht das beste.

Lieber per IF abfragen ob IP verfügbar und wenn nein nann nix machen, try und eventuell "leeres" Catch sind tödlich...(danger)

LG Pascal //It's not a bug, it's a feature. :) ;)

Hilfreich?
Kommentieren
pschmitz
  • Forum-Beiträge: 13

21.03.2018, 22:15:55 via Website

O.K mach ich.

Hilfreich?
Kommentieren