2016-06-25 4 views
-3

私は 'NameValuePair'を置くとき何らかの理由で、それはシンボルを解決できないと言います。これをどうやって解決するのですか?私は 'NameValuePair'を置くときに何らかの理由でシンボルを解決できないと言っています。これをどうやって解決するのですか?

コード:

public class MainActivity extends AppCompatActivity implements View.OnClickListener { 
    private static final int RESULT_LOAD_IMAGE = 1; 

    ImageView imageToUpload, downloadedImage; 
    Button bUploadImage, bDownloadImage; 
    EditText uploadImageName, downloadImageName; 

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

     imageToUpload = (ImageView) findViewById(R.id.imageToUpload); 
     downloadedImage = (ImageView) findViewById(R.id.downloadedImage); 

     bUploadImage = (Button) findViewById(R.id.bUploadImage); 
     bDownloadImage = (Button) findViewById(R.id.bDownloadImage); 

     uploadImageName = (EditText) findViewById(R.id.etUploadName); 
     downloadImageName = (EditText) findViewById(R.id.etDownloadName); 

     imageToUpload.setOnClickListener(this); 
     bUploadImage.setOnClickListener(this); 
     bDownloadImage.setOnClickListener(this); 




} 


    @Override 
    public void onClick(View v) { 
     switch(v.getId()){ 
      case R.id.imageToUpload: 
       Intent galleryIntent = new Intent(Intent.ACTION_PICK, MediaStore.Images.Media.EXTERNAL_CONTENT_URI); 
       startActivityForResult(galleryIntent, RESULT_LOAD_IMAGE); 
       break; 
      case R.id.bUploadImage: 
       Bitmap Image = ((BitmapDrawable) imageToUpload.getDrawable()).getBitmap(); 




       break; 
      case R.id.bDownloadImage: 

       break; 

     } 


    } 

    @Override 
    protected void onActivityResult(int requestCode, int resultCode, Intent data) { 
     super.onActivityResult(requestCode, resultCode, data); 
     if (requestCode == RESULT_LOAD_IMAGE && resultCode ==RESULT_OK && data != null) { 
      Uri selectedImage = data.getData(); 
      imageToUpload.setImageURI(selectedImage); 
     } 

     } 

     private class UploadImage extends AsyncTask<Void, Void, Void>{ 

      Bitmap image; 
      String name; 

      public UploadImage(Bitmap image, String name) { 
       this.image = image; 
       this.name = name; 
      } 

      @Override 
      protected void onPostExecute(Void aVoid) { 

       super.onPostExecute(aVoid); 
      } 

      @Override 
      protected Void doInBackground(Void... params) { 
       ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); 
       image.compress(Bitmap.CompressFormat.JPEG, 100, byteArrayOutputStream); 
       String encodedImage = Base64.encodeToString(byteArrayOutputStream.toByteArray(), Base64.DEFAULT); 

       ArrayList<NameValuePair> dataToSend = new ArrayList<>(); 
       dataToSend.add(new BasicNameValuePair("image")); 


       return null; 
      } 
     } 

    } 

どのように私は 'のNameValuePair' のエラーを解決するのですか? このエラーを解決するのに役立ちます。

ありがとう

+1

https://stackoverflow.com/questions/32949626/org-apache-http-entity-fileentity-is-deprecated-in-android-6-marshmallow HttpClientおよびその関連クラス、「NameValuePair」などは非難されましたAndroid 5.1を削除し、Android 6.0のSDKで削除しました。 – CommonsWare

+0

輸入品に記載されていますか?それともクラスをインポートしようとしませんでしたか? – f1sh

答えて

-1

を、それが、その後動作しますNameValuePairBasicNameValuePairに名前を変更します。

+1

動作しません –

+0

@LucyMatthewそうです、これはうまくいきません。 –

関連する問題