Aus irgendeinem Grund, wenn ich 'NameValuePair' setze es sagt, kann Symbol nicht auflösen. Wie kann ich das beheben?Aus irgendeinem Grund, wenn ich 'NameValuePair' setze, kann es nicht Symbol auflösen. Wie kann ich das beheben?
Der Code:
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;
}
}
}
Wie löse ich den Fehler des 'Namevaluepair'? Hilfe wird bei der Lösung dieses Fehlers hilfreich sein.
Thankyou
https://stackoverflow.com/questions/32949626/org-apache-http-entity-filentity-is-reprecated-in-android-6-marshmallow HttpClient und seine verwandten Klassen wie 'NameValuePair' wurden in der Version veraltet Android 5.1 und in Android 6.0 SDK entfernt. – CommonsWare
Ist es in Ihren Importen aufgeführt? Oder hast du nicht einmal versucht, die Klasse zu importieren? – f1sh