Main2Activity.java
1.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
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);
}
}
}