0

I am developing playing video application and taking screenshot of running video and display a screenshot in next activity, i am playing video and taking screenshot and i am not able to display screenshot in next activity please check my code and give me changes.

    BitmapDrawable bitmapDrawable = new BitmapDrawable(bm);
        image = (ImageView) findViewById(R.id.ImageView01);
     //   image.setBackgroundDrawable(bitmapDrawable);

        String bitmap = image.toString();

        System.out.println("Image getting++++++ : " + bitmap);

        Intent intent = new Intent(VideoDemo.this, ScreenshotView.class);
        intent.putExtra("BitmapImage", bitmap);

        startActivity(intent);
public class ScreenshotView extends Activity 
{       private String filename;
        private ImageButton back;


    private ImageView screenshot;

  @Override
  public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
         requestWindowFeature(Window.FEATURE_NO_TITLE);
         setContentView(R.layout.screenshot);

         screenshot =(ImageView)findViewById(R.id.screen);
         back = (ImageButton)findViewById(R.id.backbutton);
         back.setOnClickListener(new View.OnClickListener() {

            public void onClick(View arg0) {
                finish();
            }
         });

          System.gc();
          Intent i = getIntent();
          Bitmap bitmap = (Bitmap) i.getParcelableExtra("BitmapImage");
       screenshot.setImageBitmap(bitmap);
   }
}
Chandu
  • 167
  • 1
  • 5
  • 12

2 Answers2

1

Here your "bitmap" object is a string. And you are passing a string object to your next activity. That is why, you are not able to set image in you ImageView screenshot.

Mohit Verma
  • 3,025
  • 1
  • 20
  • 36
0

Can you try the below code and lemme know whether you fixed it.

Sending Object

Here is the code to send the Object from one to other class. One Important thing to send the Object is the class should implement the Serializable class.

The below Red Colored text should be same.

//MainActivity.java
Intent i = new Intent(MainActivity.this,startActivity.class);
ObjectClassName object = new ObjectClassName();
i.putExtra("THIS", Object);

Receiving Object

// startActivity.java
Intent i = getIntent();
ObjectClassName obj = (ObjectClassName) getIntent().getSerializableExtra("THIS");// 

TypeCasting needed

Lucifer
  • 29,392
  • 25
  • 90
  • 143
Pavandroid
  • 1,586
  • 2
  • 15
  • 30