我一直在谷歌,但迄今沒有運氣。 我有一個應用程序,我開始一個ActivityForResult,並在其中我把一個額外的字符串。geting extra in activityForResult
編輯 我無法發佈一個複雜的代碼,因爲我是在我的桌子,我剛收到我的筆記本電腦所以這裏的代碼
的ActivityForResult:
@Override
protected void onCreate(Bundle saved) {
super.onCreate(saved);
setContentView(R.layout.camera);
a = new AQuery(this);
output = getIntent().getExtras().getString("output");//Here, nothing is passed!!!!!!!!
//Log.d("out",output);
/** Check if this device has a camera */
if (this.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_ANY)){
text ="yes";
//now we check the cam features
if(this.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT))
front ="yes";
if(this.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FLASH))
flash = "yes";
if(this.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA))
back= "yes";
}else{
text = "This device does not have a camera";
//---set the data to pass back---
data.putExtra("vid",text);
setResult(RESULT_OK, data);
//---close the activity---
finish();
}
if (c != null) {
c.release();
c = null;
}
m = new MediaRecorder();
c = getCameraInstance(this);
Camera.Parameters parameters =
c.getParameters();
// Create our Preview view and set it as the content of our activity.
mPreview = new CameraPreview(this, c);
int orien =getResources().getConfiguration().orientation;
if(orien ==1){
parameters.setRotation(0); // set rotation to save the picture
c.setDisplayOrientation(90);
parameters.setPictureSize(640, 480);
PIC_ORIENTATION = "landscape";
}else{
parameters.setRotation(0); // set rotation to save the picture
c.setDisplayOrientation(0);
parameters.setPictureSize(640, 480);
PIC_ORIENTATION = "portrait";
}
if (Camera.getNumberOfCameras() < 2) {
//TODO
}
fileUri = getOutputMediaFileUri();
c.setParameters(parameters);
m.setCamera(c);
FrameLayout preview = (FrameLayout) findViewById(R.id.camera_preview);
preview.addView(mPreview);
}
和發射意圖在價值
cam.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
Intent i = new Intent(Mess.this,Cam.class);
i.putExtra("output", vids);
startActivityForResult(i,2);
dialog.cancel();//TODO
}
});
沒有傳遞..它只是空... 這是activityForResult ......但在短短的活動,我得到的通過價值。
從哪裏試圖檢索數據?請發佈與這兩個活動相關的代碼 – 2014-09-10 23:59:31
您的意思是「什麼都不通過」是什麼意思? Extras包是否爲空? 'getString()'結果爲空嗎? – emerssso 2014-09-11 00:03:55
爲了將來的參考,您應該發佈更完整的示例代碼。特別是,你應該給周圍的類和包含代碼的方法。 – 2014-09-11 00:31:49