我在第二次活动中获得额外收入有些麻烦。
在活动A中:
DECLARE @response NVARCHAR(max);
--get the data from the provider as JSON
EXECUTE dbo.GetWebService 'https://powercomm.simprosuite.com/api/v1.0/companies/1/schedules/?access.token=383abc4084a2b8dcbf508252e4a0313762fd623b&Date=***2018-11-21***&Staff.ID=***249***',
@response OUTPUT;
BEGIN
--Insert into Schedules
--(SchedID, Type, JobNo, TotalHrs, EmployeeID, SchedDate, StartTime, FinishTime)
Select SchedID, Type, JobNo, TotalHrs, EmployeeID, SchedDate, StartTime, FinishTime
FROM OpenJson(@response) ;
with (SchedID numeric N'$.ID', Type CHAR(15) N'$.Type', JobNo nvarchar(5) N'$.Reference', TotalHrs Dec(4,2) N'$.TotalHours', SchedDate Date N'$.Date', EmployeeID numeric(6) N'$.Staff.ID', Blocks nvarchar(max) N'$.Blocks' as JSON)
OUTER APPLY
OpenJson(Blocks)
WITH
(StartTime datetimeoffset N'$.ISO8601StartTime', FinishTime datetimeoffset N'$.ISO8601EndTime' );
END;
go
在活动B中:
...
// start Activity B
Intent i = new Intent(getBaseContext(), ActivityB.class
startActivityForResult(i, 0);
...
protected void onActivityResult(int requestCode, int resultCode, Intent data){
// get the extras from data
String extra = data.getExtras().getString("EXTRA1");
}
问题是-在活动a中-'onActivityResult'的数据中未包含任何额外内容。
这里错了吗?
答案 0 :(得分:0)
您将立即结果放在Intent
中,因此应调用data.getStringExtra("EXTRA1')
而不是data.getExtras().getString("EXTRA1")
,因为它只会返回空的Bundle
。
您的requestCode
也应大于0:
int:如果> = 0,则当>活动退出时,此代码将在onActivityResult()中返回