Reputation: 953
I referred several posts to pass arguments to camera activity but of no use. Below is my code.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_photocapture);
ib = (ImageButton)findViewById(R.id.clickme);
ib.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
Intent cameraIntent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
cameraIntent.putExtra("s", 10);
startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
}
});
}
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == CAMERA_PIC_REQUEST && resultCode == RESULT_OK) {
Bundle b = getIntent().getExtras();
String s = b.getString("s");//(String)data.getExtras().get("s");
Toast.makeText(getApplicationContext(), s, Toast.LENGTH_SHORT).show();
Bitmap photo = (Bitmap) data.getExtras().get("data");
ib.setImageBitmap(photo);
}
}
But i am not able to pass them successfully. People who have been able to do it successfully, please help!
Upvotes: 2
Views: 1627
Reputation: 953
Hi thanks for the replies, i added my param with requestCode, and at the receiver received and proceeded with it. Thanks for the reply!
Upvotes: 0
Reputation: 14138
You set param to camera intent and you ask param from another actvity. This not right. If you want send spesific setting param to camera activity you read this documentation:
If you need pass not settings params to camera activity, then you create global variable in current activity and use it is in onActivityResult method.
Upvotes: 1