我为我的最后一年项目创建触发器和操作应用程序,
我将子活动结果返回给中间活动,然后向该活动添加一些数据并将其再次发送到主要活动,
我为 Trigger 子模块和 Action 子模块做了,两者都喜欢相同的编码......
触发模块工作正常,但是当动作模块运行应用程序被强制停止
错误是
E/AndroidRuntime(5104): java.lang.RuntimeException: Failure delivering result ResultInfo{who=null, request=1, result=-1, data=Intent { (has extras) }} to activity {mani.droid.mechanize/mani.droid.mechanize.ActionListActivity}: java.lang.NullPointerException
子 onActivityResult
public void onSave(View v)
{
if(txtNum.length() != 0)
{
String strTmp = null;
Intent resultInt = new Intent();
strTmp = txtNum.getText().toString();
resultInt.putExtra("Num", strTmp);
resultInt.putExtra("SubName", strTmp);
setResult(Activity.RESULT_OK, resultInt);
finish();
}
else
Toast.makeText(getApplicationContext(), "Please enter number or choose from contact", Toast.LENGTH_SHORT).show();
}
中间 onActivityResult
//getting result from other activity and sending to action list activity
@Override
public void onActivityResult(int reqCode, int resultCode, Intent data) {
super.onActivityResult(reqCode, resultCode, data);
if(resultCode == Activity.RESULT_OK)
{
switch(reqCode)
{
case 1:
data.putExtra("ActionName", txtAction);
setResult(Activity.RESULT_OK, data);
finish();
break;
}
}
}
主 onActivityResult
//Getting Trigger parameters and adding to list
@Override
public void onActivityResult(int reqCode, int resultCode, Intent data) {
super.onActivityResult(reqCode, resultCode, data);
if(resultCode == Activity.RESULT_OK)
{
switch(reqCode)
{
case 1:
if (data.equals(null))
{
Toast.makeText(context, "Intent is Null", Toast.LENGTH_SHORT).show();
}
else
{
//String actName = data.getStringExtra("ActionName");
String subName = data.getStringExtra("SubName");
Toast.makeText(context, subName, Toast.LENGTH_SHORT).show();
}
break;
}
}
}