【发布时间】:2016-02-24 07:02:41
【问题描述】:
我正在开发一个应用程序。最小 SDK 为 14。现在我要从 Fragment 打开新的 Activity,当用户单击 Fragment 上的按钮时。
//打开新活动的代码
newFavoriteFAB.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent mIntent = new Intent(getActivity(), CategoriesActivity.class);
Bundle mBundle = new Bundle();
mBundle.putInt(BundleConstants.OPERATION_TYPE, OperationTypes.ADD_FAVORITE);
mIntent.putExtras(mBundle);
startActivityForResult(mIntent, ActivityStartRequestCode.ADD_FAVORITE);
}
});
//activity onCreate方法,试图打开
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
Log.d(TAG, "onCreate");
//here, when i am going to get it, i see that bundle argument is null
我试图通过活动,但它告诉我:调用需要 API 级别 16。因为我使用 API 14 作为最低要求。
getActivity().startActivityForResult(mIntent, ActivityStartRequestCode.ADD_FAVORITE, mBundle);
请提供可行的解决方案。 谢谢
【问题讨论】:
标签: android fragment android-support-library