开发者

Reading EXIF data to textView in new Activity

I've been able to pass a selected image from grid view to a new full screen activity. I am now trying to capture the EXIF data from the image and pass it into a new activity.

The first activity of passing the int from grid view seems to be working fine.

public class test extends Activity {
public static int pos;


@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.thumb);



    GridView gridview = (GridView) findViewById(R.id.thumbgridview);
    gridview.setAdapter(new tImageAdapter(this));


    gridview.setOnItemClickListener(new OnItemClickListener() {
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
             Intent intent = new Int开发者_运维百科ent(test.this,test2.class);
                pos=position;
                intent.putExtra("pos", pos);
                startActivity(intent);
            finish();




        }
    });}
}

The second activity which displays the full image seems to be working fine.

public class test2 extends Activity {


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
       setContentView(R.layout.full);


        Bundle bundle= getIntent().getExtras();
        ImageView image = (ImageView) findViewById(R.id.imagefull);

        int pos = bundle.getInt("pos");
        bundle.getFloat(ExifInterface.TAG_MAKE);

        tImageAdapter obj = new tImageAdapter(this);
        image.setImageResource(obj.tThumbIds[pos]);

        Button bDIR = (Button) findViewById(R.id.bDIR);
        bDIR.setOnClickListener(new OnClickListener() {

            public void onClick(View v) {

                Intent intent = new Intent(test2.this,Direct.class);                   

                intent.putExtra(ExifInterface.TAG_MAKE, 0);
                startActivity(intent);
            finish();







            }


        });

Now when I proceed to the final activity all I am seeing in the text view is the word Make.

    public class Direct extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
           setContentView(R.layout.newthumb);

           Bundle bundle= getIntent().getExtras();

            bundle.getFloat(ExifInterface.TAG_MAKE);

    TextView textview = (TextView) findViewById(R.id.dirtext);
    textview.setText(ExifInterface.TAG_MAKE);



    }   
}

I am not getting any errors in debug and there hasn't been a single force close issue. Is there something I am missing? I've only been working with java for a couple weeks but this type of activity seems like it should be doable. (or I'm just an idiot)

Thanks!


bundle.getFloat(ExifInterface.TAG_MAKE); does not read anything. You are nowhere actually reading the Exif data from the image file. You simply are showing in the TextView the content of the static String named ExifInterface.TAG_MAKE.

The documentation is available: ExifInterface. You will need to do something like:

ExifInterface exifReader = new ExifInterface(filename);
textview.setText(exifReader.getAttribute(ExifInterface.TAG_MAKE));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜