I recently got updated to Android 4.3 and the stock video camera started acting a little weird whenever I started it with an Intent from my app.
At first it would just crash and say "Gallery stopped responding". After a little while, I was able to record a video, but clicking on done returned a null URI to my app, which made it crash!
So I set out testing a 2.3.4 device with the same code. The video app returned a proper URI I could use on that device. The same code worked perfectly fine before I got 4.3 (had 4.2.2 stock Galaxy Nexus)
Here's an activity that get a null URI from the stock camera app of 4.3 but works fine on devices with 4.2.2 and less.
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Button pick = (Button) findViewById(R.id.button1);
pick.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
startActivityForResult(takeVideoIntent, 123);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(resultCode == RESULT_OK){
if(requestCode == 123){
VideoView videoView = (VideoView) findViewById(R.id.videoView1);
videoView.setVideoURI(data.getData());
Log.d("Video", "URI "+data.getData());
}
}
super.onActivityResult(requestCode, resultCode, data);
}
}
What do I do so that this never happens? Does this mean that this will work differently with other camera apps on different manufacturer devices?