I'm new to this page.
I am trying to create an app where you can decide whether to take a picture or upload it from the phone gallery. I found this code in one of the questions here but I have a question since I have not used these functions.
The code I leave here is the same, the case is that it is not for this line of code according to the answer is to handle it by category but I still do not understand how to correct this error if it is another class or a variable.
public class CreateBits extends AppCompatActivity {
EditText editText;
private static int RESULT_LOAD_IMG = 1;
String imgDecodableString;
Button nxtActivity;
SharedPreferencesController spc;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_create_bits);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
editText = (EditText)findViewById(R.id.edtTextNameBit);
spc = new SharedPreferencesController(this);
}
public void addBit(View view){
String bitName = editText.getText().toString();
App.addBits(bitName, imgDecodableString, spc.getCategoryPID());
finish();
}
public void Cancell(View view){
finish();
}
public void addImage(View view){
Intent galleryIntent = new Intent(Intent.ACTION_PICK,
android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
// Start the Intent
startActivityForResult(galleryIntent, RESULT_LOAD_IMG);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
try {
// When an Image is picked
if (requestCode == RESULT_LOAD_IMG && resultCode == RESULT_OK
&& null != data) {
// Get the Image from data
Uri selectedImage = data.getData();
//Log.i("RegirstrarPerfil",data.toString());
String[] filePathColumn = {MediaStore.Images.Media.DATA};
// Get the cursor
Cursor cursor = getContentResolver().query(selectedImage,
filePathColumn, null, null, null);
// Move to first row
cursor.moveToFirst();
int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
imgDecodableString = cursor.getString(columnIndex);
cursor.close();
Log.i("Main", imgDecodableString);
ImageView imgView = (ImageView) findViewById(R.id.imgCreateBit);
// Set the Image in ImageView after decoding the String
imgView.setImageBitmap(BitmapFactory
.decodeFile(imgDecodableString));
} else {
Toast.makeText(this, "You haven't picked Image",
Toast.LENGTH_LONG).show();
}
} catch (Exception e) {
Toast.makeText(this, "Something went wrong", Toast.LENGTH_LONG)
.show();
}
}
}
CategoryUtility
marks it in red
boolean result = CategoryUtility.checkPermission(Register_co.this);
case CategoryUtility.MY_PERMISSIONS_REQUEST_READ_EXTERNAL_STORAGE: