java.lang.UnsupportedOperationException..崩溃

java.lang.UnsupportedOperationException..崩溃,java,android,google-api,Java,Android,Google Api,我在应用程序启动时在logcat中遇到此错误,然后崩溃 03-19 15:41:34.644 5167-5167/com.example.abdulmajeedmohammad.insertertels E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.abdulmajeedmohammad.insertertels, PID: 5167 java.lang.RuntimeException: Unable to start

我在应用程序启动时在logcat中遇到此错误,然后崩溃

03-19 15:41:34.644 5167-5167/com.example.abdulmajeedmohammad.insertertels E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.abdulmajeedmohammad.insertertels, PID: 5167
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.abdulmajeedmohammad.insertertels/com.example.abdulmajeedmohammad.insertertels.MainActivity}: java.lang.UnsupportedOperationException
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3149)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3248)
    at android.app.ActivityThread.access$1000(ActivityThread.java:197)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1681)
    at android.os.Handler.dispatchMessage(Handler.java:102)
    at android.os.Looper.loop(Looper.java:145)
    at android.app.ActivityThread.main(ActivityThread.java:6872)
    at java.lang.reflect.Method.invoke(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:372)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199)
 Caused by: java.lang.UnsupportedOperationException
    at java.util.AbstractList.add(AbstractList.java:404)
    at java.util.AbstractList.add(AbstractList.java:425)
    at android.widget.ArrayAdapter.add(ArrayAdapter.java:179)
    at com.example.abdulmajeedmohammad.insertertels.MainActivity.onCreate(MainActivity.java:83)
    at android.app.Activity.performCreate(Activity.java:6550)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1120)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3102)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3248) 
    at android.app.ActivityThread.access$1000(ActivityThread.java:197) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1681) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:145) 
    at android.app.ActivityThread.main(ActivityThread.java:6872) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at java.lang.reflect.Method.invoke(Method.java:372) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1404) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1199) 
这是活动课

public class MainActivity extends AppCompatActivity implements GoogleApiClient.ConnectionCallbacks
    , GoogleApiClient.OnConnectionFailedListener {

private Spinner spinner;
private EditText name, number, fax, street;
private Button takePictureButton, sendButton;
private ArrayAdapter<String> listTypesAdapter;
private final static int REQUEST_IMAGE_CAPTURE = 1;
String type = "";
Bitmap photo;
Uri fileUri;
Uri selectedImage;
String bitmap1, picturePath;
GoogleApiClient googleApiClient;
Location lastLocation;
String location;
String Url = "";
RequestQueue requestQueue;
ImageView imageView;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    buildGoogleApiClient();

    if (googleApiClient != null) {
        googleApiClient.connect();
    }

    spinner = (Spinner) findViewById(R.id.types);

    name = (EditText) findViewById(R.id.name);
    number = (EditText) findViewById(R.id.number);
    fax = (EditText) findViewById(R.id.fax);
    street = (EditText) findViewById(R.id.street);
    takePictureButton = (Button) findViewById(R.id.takePictureButton);

    String[] list = getResources().getStringArray(R.array.types_array);

    listTypesAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, list);
    listTypesAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    spinner.setAdapter(listTypesAdapter);

        listTypesAdapter.add("الرجاء الإختيار");
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {

            switch (position) {

                case 0:
                    type = "جهة حكومية";
                    break;
                case 1:
                    type = "مستشفى - مستوصف";
                    break;
                case 2:
                    type = "مطعم";
                    break;
                case 3:
                    type = "جهة خيرية";
                    break;
                case 4:
                    type = "قطع غيار وزينة السيارات";
                    break;
                case 5:
                    type = "صيدلية";
                    break;
                case 6:
                    type = "تموينات - سوبر ماركت";
                    break;
                case 7:
                    type = "ملابس وكماليات";
                    break;
                case 8:
                    type = "ملابس وكماليات رجالية";
                    break;
                case 9:
                    type = "أجهزة الكترونية";
                    break;

            }
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {

        }
    });


}

private void takeImage() {
    Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    if (intent.resolveActivity(getPackageManager()) != null) {
        startActivityForResult(intent, REQUEST_IMAGE_CAPTURE);
    }
}

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_IMAGE_CAPTURE && resultCode == RESULT_OK) {
        selectedImage = data.getData();
        photo = (Bitmap) data.getExtras().get("data");

        String[] filepath = {MediaStore.Images.Media.DATA};

        Cursor cursor = getContentResolver().query(selectedImage, filepath, null, null, null);
        cursor.moveToFirst();

        int columnIndex = cursor.getColumnIndex(filepath[0]);
        picturePath = cursor.getColumnName(columnIndex);
        cursor.close();

        Bitmap photo = (Bitmap) data.getExtras().get("data");
        imageView = (ImageView) findViewById(R.id.tokenImage);
        imageView.setImageBitmap(photo);

    }
}

protected synchronized void buildGoogleApiClient() {


    googleApiClient = new GoogleApiClient.Builder(this)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .addApi(LocationServices.API)
            .build();
}

@Override
public void onConnected(Bundle bundle) {
    if (ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(this, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        // TODO: Consider calling
        //    ActivityCompat#requestPermissions
        // here to request the missing permissions, and then overriding
        //   public void onRequestPermissionsResult(int requestCode, String[] permissions,
        //                                          int[] grantResults)
        // to handle the case where the user grants the permission. See the documentation
        // for ActivityCompat#requestPermissions for more details.
        return;
    }
    lastLocation = LocationServices.FusedLocationApi.getLastLocation(googleApiClient);

    location = "Latitude: " + String.valueOf(lastLocation.getLatitude()) + "Longitude: " + String.valueOf(lastLocation.getLongitude());

    }

    @Override
    public void onConnectionSuspended(int i) {

        location = "Suspended";
    }

    @Override
    public void onConnectionFailed(ConnectionResult connectionResult) {
        location = "Failed";
    }


private void send() {

    if (name.getText().toString().equalsIgnoreCase("") || name.getText() == null) {
        Toast.makeText(getApplicationContext(), "الرجاء إدخال الإسم", Toast.LENGTH_SHORT).show();
    } else if (number.getText().toString().equalsIgnoreCase("") || number.getText() == null) {
        Toast.makeText(getApplicationContext(), "الرجاء إدخال الرقم", Toast.LENGTH_SHORT).show();
    } else if (fax.getText().toString().equalsIgnoreCase("") || fax.getText() == null) {
        Toast.makeText(getApplicationContext(), "الرجاء إدخال الفاكس أو كتابة none", Toast.LENGTH_SHORT).show();
    } else if (street.getText().toString().equalsIgnoreCase("") || street.getText() == null) {
        Toast.makeText(getApplicationContext(), "الرجاء كتابة الشارع", Toast.LENGTH_SHORT).show();
    } else if (location.equals("Suspended")) {
        Toast.makeText(getApplicationContext(), "يرجى تشغيل الجي بي إس لتحديد الموقع", Toast.LENGTH_SHORT).show();
    } else if (location.equals("Failed")) {
        Toast.makeText(getApplicationContext(), "فشل في الحصول على الموقع", Toast.LENGTH_SHORT).show();
    } else if (type.equals("")){
        Toast.makeText(getApplicationContext(), "الرجاء اختيار نوع الموقع", Toast.LENGTH_SHORT).show();
    } else if (photo == null) {
        Toast.makeText(getApplicationContext(), "يرجى أخذ صورة للموقع", Toast.LENGTH_SHORT).show();
    } else {


        Bitmap bm = BitmapFactory.decodeFile(picturePath);
        ByteArrayOutputStream bao = new ByteArrayOutputStream();
        bm.compress(Bitmap.CompressFormat.JPEG, 50, bao);
        byte[] by = bao.toByteArray();
        bitmap1 = Base64.encodeToString(by, Base64.DEFAULT);

        requestQueue = Volley.newRequestQueue(this);

        StringRequest request = new StringRequest(Request.Method.POST, Url,

                new Response.Listener<String>() {
                    @Override
                    public void onResponse(String response) {

                        AlertDialog.Builder alertDialog = new AlertDialog.Builder(MainActivity.this);
                        alertDialog.setMessage("تم الإرسال بنجاح");
                        alertDialog.setPositiveButton("موافق", new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                finish();
                            }
                        });
                      alertDialog.show();

                        name.setText("");
                        number.setText("");fax.setText("");street.setText("");
                        imageView.setImageBitmap(null);
                    }
                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {

                        Toast.makeText(getApplicationContext(),"حدث خطأ في الإرسال", Toast.LENGTH_SHORT).show();

                    }
                }


        );
      requestQueue.add(request);
    }

}
}
公共类MainActivity扩展AppCompative实现GoogleAppClient.ConnectionCallbacks
,GoogleApiClient.OnConnectionFailedListener{
私人纺纱机;
私人编辑姓名、号码、传真、街道;
私有按钮takePictureButton,sendButton;
专用阵列适配器列表类型适配器;
私有最终静态int请求\图像\捕获=1;
字符串类型=”;
位图照片;
urifileuri;
Uri选择图像;
字符串bitmap1,picturePath;
GoogleapClient GoogleapClient;
地理位置;
字符串位置;
字符串Url=“”;
请求队列请求队列;
图像视图图像视图;
@凌驾
创建时受保护的void(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
buildGoogleAppClient();
if(googleApiClient!=null){
googleApiClient.connect();
}
微调器=(微调器)findViewById(R.id.types);
name=(EditText)findViewById(R.id.name);
number=(EditText)findViewById(R.id.number);
传真=(编辑文本)findViewById(R.id.fax);
街道=(编辑文本)findViewById(R.id.street);
takePictureButton=(按钮)findViewById(R.id.takePictureButton);
String[]list=getResources().getStringArray(R.array.types\u array);
listTypesAdapter=new ArrayAdapter(这是android.R.layout.simple\u微调器\u项,列表);
listTypesAdapter.setDropDownViewResource(android.R.layout.simple\u微调器\u下拉菜单\u项);
spinner.setAdapter(listTypesAdapter);
listTypesAdapter.add(“列表类型”);
spinner.setOnItemSelectedListener(新的AdapterView.OnItemSelectedListener(){
@凌驾
已选择公共视图(AdapterView父视图、视图视图、整型位置、长id){
开关(位置){
案例0:
type=“جه㶡حومية”;
打破
案例1:
type=“مسشفى-مستو”;
打破
案例2:
type=“مطعم”;
打破
案例3:
type=“جه㶡㶡㶡”;
打破
案例4:
类型为;
打破
案例5:
type=“يدلية”;
打破
案例6:
类型为;
打破
案例7:
type=“ملبسومايت”;
打破
案例8:
类型为;
打破
案例9:
类型为;
打破
}
}
@凌驾
未选择公共无效(AdapterView父级){
}
});
}
私有图像(){
意向意向=新意向(MediaStore.ACTION\u IMAGE\u CAPTURE);
if(intent.resolveActivity(getPackageManager())!=null){
startActivityForResult(意图、请求、图像捕获);
}
}
@凌驾
受保护的void onActivityResult(int请求代码、int结果代码、意图数据){
if(requestCode==REQUEST\u IMAGE\u CAPTURE&&resultCode==RESULT\u OK){
选择edimage=data.getData();
photo=(位图)data.getExtras().get(“数据”);
字符串[]文件路径={MediaStore.Images.Media.DATA};
Cursor Cursor=getContentResolver().query(selectedImage,filepath,null,null);
cursor.moveToFirst();
int columnIndex=cursor.getColumnIndex(文件路径[0]);
picturePath=cursor.getColumnName(columnIndex);
cursor.close();
位图照片=(位图)数据.getExtras().get(“数据”);
imageView=(imageView)findViewById(R.id.tokenImage);
设置图像位图(照片);
}
}
受保护的同步无效BuildGoogleAppClient(){
GoogleapClient=新的GoogleapClient.Builder(此)
.addConnectionCallbacks(此)
.addOnConnectionFailedListener(此)
.addApi(LocationServices.API)
.build();
}
@凌驾
未连接的公共空间(捆绑包){
if(ActivityCompat.checkSelfPermission(this,Manifest.permission.ACCESS\u FINE\u LOCATION)!=PackageManager.permission\u已授予和&ActivityCompat.checkSelfPermission(this,Manifest.permission.ACCESS\u LOCATION)!=PackageManager.permission\u已授予){
考虑到呼叫
//ActivityCompat#请求权限
//在此处请求缺少的权限,然后覆盖
//public void onRequestPermissionsResult(int-requestCode,字符串[]权限,
//int[]格兰特结果)
//处理用户授予权限的情况。请参阅文档
//对于ActivityCompat,请请求权限以获取更多详细信息。
返回;
}
lastLocation=LocationServices.FusedLocationApi.getLastLocation(GoogleAppClient);
location=“Latitude:”+String.valueOf(lastLocation.getLatitude())+“Longitude:”+String.valueOf(lastLocation.getLongitude());
}
@凌驾
公共空间连接暂停(int i){
位置=“暂停”;
}
@凌驾
公共无效onConnectionFailed(ConnectionResult ConnectionResult){
location=“失败”;
}
私有无效发送(){
if(name.getText().toString().equalsIgnoreCase(“”| | name.getText()==null){
Toast.makeText(getApplicationContext(),“Toast.LENGTH”show();
}else if(number.getText().toString().equalsIgnoreCase(“”| | number.getText()==null){
Toast.makeText(getApplicationContext(),“Toast