Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/218.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android应用程序在一台设备上崩溃,而不是在另一台设备上崩溃_Android_Android Fragments_Android Version - Fatal编程技术网

Android应用程序在一台设备上崩溃,而不是在另一台设备上崩溃

Android应用程序在一台设备上崩溃,而不是在另一台设备上崩溃,android,android-fragments,android-version,Android,Android Fragments,Android Version,下面的代码使应用程序在魅族手机上崩溃,而不是在我的galaxy s2上。 (魅族版本较新,但不是我的,也不是这里,所以我不知道是什么版本) public void onClick(视图v){ et=(EditText)findViewById(R.id.searchEdit); int newArrIndex=0; Log.d(“BeforeFirst”、“BeforeFirst”); String[]newArr=新字符串[contactsArray.length]; 对于(int i=0;我

下面的代码使应用程序在魅族手机上崩溃,而不是在我的galaxy s2上。 (魅族版本较新,但不是我的,也不是这里,所以我不知道是什么版本)

public void onClick(视图v){
et=(EditText)findViewById(R.id.searchEdit);
int newArrIndex=0;
Log.d(“BeforeFirst”、“BeforeFirst”);
String[]newArr=新字符串[contactsArray.length];

对于(int i=0;我感谢你,但我两次说我没有手机,所以没有Logcatal我们能做的就是猜测,如果我根据经验猜测,我会说contactsArray可能是空的。当然它可能是任何东西。最好的办法是检查Google Play是否报告了错误,或者当然安装一个错误报告库:谢谢你,詹姆斯,但是看,它仍然有效我的galaxy。所以contactArray不是空的。我99%确定错误出现在循环之后,或者是EditText…EditText以及我对Bundle和Fragment所做的工作对于大多数android版本都是一样的吗?
public void onClick(View v){
    et= (EditText) findViewById(R.id.searchEdit);
    int newArrIndex= 0;
    Log.d("BeforeFirst","BeforeFirst");
    String [] newArr=new String [contactsArray.length];
    for (int i=0;i<contactsArray.length;i++){
        if(et.getText().toString().contains("blibli")){
            newArr[0]="bla";
            newArr[1]="blo";
            break;
        }
        else if(et.getText().toString().contains("blabla")){
            newArr[0]="bli";
            newArr[1]="blu";
            break;
        }
        if(contactsArray[i].contains(et.getText().toString())){
            newArr[newArrIndex]=contactsArray[i];
            newArrIndex++;
        }
        et.setSelected(false);
    }

    Bundle bundle=new Bundle();
    bundle.putStringArray("contacts",newArr);

    MyPlaceholderFragment frag=new MyPlaceholderFragment();
    frag.setArguments(bundle);
    getSupportFragmentManager().beginTransaction()
            .add(R.id.container, frag)
            .commit();
    setContentView(R.layout.activity_search);
}