package com.example.feelhut;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
public class editprofile extends AppCompatActivity {
ImageButton proileimagebutton;
private static final int ImageRequest=1;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
proileimagebutton= findViewById(R.id.edit_profile);
proileimagebutton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_GET_CONTENT);
intent.setType("imageeeeeee/");
There ImageRequest showing Error in startActivityForResult. Means I am not able to identify image request here.
startActivityForResult(intent.ImageRequest);
}
});
}
}
public class editprofile extends AppCompatActivity {
ImageButton proileimagebutton;
private static final int ImageRequest=1;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//no content view? add like this setContentView(R.layout.yourViewLayout);
proileimagebutton= findViewById(R.id.edit_profile);
proileimagebutton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent intent = new Intent();
intent.setAction(Intent.ACTION_GET_CONTENT);
intent.setType("image/*");
startActivityForResult(intent,ImageRequest);
}
});
}
@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == ImageRequest&& resultCode == RESULT_OK) {
// your ImageView.setUri(data.getData();
}
}
}