Main2Activity.java 1.67 KB
package com.example.ksi.refrigerator;

import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.provider.MediaStore;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;

public class Main2Activity extends AppCompatActivity {

    Intent intent;
    ImageView barcode ;
        Item item = new Item();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main2);

        barcode = findViewById(R.id.imageView);

        intent = getIntent();
        Bitmap img = (Bitmap)intent.getParcelableExtra("barcode");
        barcode.setImageBitmap(img);
    }

    public void selfInput(View view){
        Intent intent = new Intent(this,Main3Activity.class);
        intent.setFlags(Intent.FLAG_ACTIVITY_FORWARD_RESULT);
        intent.putExtra("item",item);
        startActivity(intent);
        finish();
    }
    public void photoAgain(View view){
        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
        if(intent.resolveActivity(getPackageManager())!=null) {
            startActivityForResult(intent, 1);
        }
    }
    public void add(View view){

    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        //super.onActivityResult(requestCode, resultCode, data);

        Bitmap img;
        if(requestCode == 1 && resultCode == RESULT_OK)
        {
            Bundle extras = data.getExtras();
            img = (Bitmap) extras.get("data");
            barcode.setImageBitmap(img);
        }
    }
}