如何修复:线程连接失败'Binder_1'线程'Binder_2'失败



所以我使用"Andy Emulator"在Android Studio上运行我的调试器,它几乎与Android Studio的Android模拟器相同,然后我收到了运行时错误11-01 13:56:57.796 8967-8976/?I/Android运行时:注意:连接线程"Binder_1"失败11-01 13:56:58.530 8997-9006/?I/Android运行时:注意:连接线程"Binder_2"失败那么请问如何解决它?我不知道这是否有帮助,但是当我在Bluestacks上运行我的应用程序时,它会冻结屏幕冻结,按钮也不再可点击在我单击它之后,它不会崩溃,它会冻结:)。

这是我的代码,如果它有帮助:

    package com.example.android.quizgenerator;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.Editable;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;
import static android.R.attr.x;
public class MainActivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    }

    public void Print(View view)
    {
        //get the text
        EditText nameField = (EditText) findViewById(R.id.fill_here);
        Editable text_ar = nameField.getText();
        String s = text_ar.toString(); //this is the string that is going to be cut
        String s2 = ""; //this is the final string
        String MyText = ""; //this is the stringwhere we accumulate characters
        String x, x1, x2, x3, x4 = "";
        //the counter i, the check if !=a,an,the variable t
        int n = 0;
        int i = 0;
        int t = 0;
        //Edit the text
        //add the word the translation of X is
        while (!(s.equals(""))) {
            //only assign this value if the charAt(i) exists
            if (s.length() != 0)
                x = s.charAt(i) + "";
            else
                x = "";
            if (s.length() > 1) {
                x1 = s.charAt(i + 1) + "";
            } else
                x1 = "";
            if (s.length() > 2) {
                x2 = s.charAt(i + 2) + "";
            } else
                x2 = "";
            if (s.length() > 3) {
                x3 = s.charAt(i + 3) + "";
            } else
                x3 = "";
            if (s.length() > 4) {
                x4 = s.charAt(i + 4) + "";
            } else
                x4 = "";
            MyText = MyText + s.charAt(i);

            //we should have space the space to enter here
            if (x.equals(" ") && x1.equals("t") && x2.equals("h") && x3.equals("e") && x4.equals(" ")) {
                //get Mytext and update s
                s = s.replace("the ", ""); //deletes 'the ' from s
                if (s.indexOf(" ") != -1) {
                    n = s.indexOf(" "); //index of the end of MyText
                    MyText = s.substring(0, n);//gets the word after 'the ' that was just deleted and supposing that there's a space
                    //to determine the end of MyText: no space no more words
                } else {
                    MyText = s.substring(0, s.length());//there's no space to determine the end of MyText
                    // which means it is the end of the sentence: no space no more words
                }
                s = s.replace(MyText, ""); //gets s Minus MyText and keep the space after MyText
                MyText = "the translation of the " + MyText + " is"; //added the sentence in the beginning
                s2 = s2 + "/n" + MyText; //accumulated all the words in a text
                t++;
                MyText = "";
                //delete the string space the space
            }
            //we should have space an space to enter here
            if (x.equals(" ") && x1.equals("a") && x2.equals("n") && x3.equals(" ")) {
                //get Mytext and update s
                s = s.replace("an ", ""); //deletes 'the ' from s
                if (s.indexOf(" ") != -1) {
                    n = s.indexOf(" "); //index of the end of MyText
                    MyText = s.substring(0, n);//gets the word after 'the ' that was just deleted and supposing that there's a space
                    //to determine the end of MyText: no space no more words
                } else {
                    MyText = s.substring(0, s.length());//there's no space to determine the end of MyText
                    // which means it is the end of the sentence: no space no more words
                }
                s = s.replace(MyText, ""); //gets s Minus MyText and keep the space after MyText
                MyText = "the translation of an " + MyText + " is"; //added the sentence in the beginning
                s2 = s2 + "/n" + MyText; //accumulated all the words in a text
                t++;
                MyText = "";
            }
            //we should have space a space to enter here
            if (x.equals(" ") && x1.equals("a") && x2.equals(" ")) {
                //get Mytext and update s
                s = s.replace("a ", ""); //deletes 'the ' from s
                if (s.indexOf(" ") != -1) {
                    n = s.indexOf(" "); //index of the end of MyText
                    MyText = s.substring(0, n);//gets the word after 'the ' that was just deleted and supposing that there's a space
                    //to determine the end of MyText: no space no more words
                } else {
                    MyText = s.substring(0, s.length());//there's no space to determine the end of MyText
                    // which means it is the end of the sentence: no space no more words
                }
                s = s.replace(MyText, ""); //gets s Minus MyText and keep the space after MyText
                MyText = "the translation of a " + MyText + " is"; //added the sentence in the beginning
                s2 = s2 + "/n" + MyText; //accumulated all the words in a text
                t++;
                MyText = "";
            }
            //we should have space anyletter!=the,a,an
            if (x.equals(" ") && (t == 0)) //this is a word
            {
                //get Mytext and update s
                s = s.replace(" ", ""); //deletes 'the ' from s
                if (s.indexOf(" ") != -1) {
                    n = s.indexOf(" "); //index of the end of MyText
                    MyText = s.substring(0, n);//gets the word after 'the ' that was just deleted and supposing that there's a space
                    //to determine the end of MyText: no space no more words
                } else {
                    MyText = s.substring(0, s.length());//there's no space to determine the end of MyText
                    // which means it is the end of the sentence: no space no more words
                }
                s = s.replace(MyText, ""); //gets s Minus MyText and keep the space after MyText
                MyText = "the translation of " + MyText + " is"; //added the sentence in the beginning
                s2 = s2 + "/n" + MyText; //accumulated all the words in a text
                MyText = "";
            }
        }

        //Print the new text
        TextView y = (TextView) findViewById(R.id.print_here);
        y.setText(s2);
    }
}

当我试图解决这个问题时,我发现了第二个问题: 为什么安卓应用程序冻结?

所以我发现了一个问题,当我有一个无限循环时 我的应用程序安卓应用程序的反应是冻结。

为什么安卓应用程序冻结

所以我发现了一个问题,似乎当我在我的应用程序中有一个无限循环时,Android 应用程序对此的反应是冻结的。

最新更新