Android ConnectivityManager是错误的无法访问的声明'

时间:2015-08-11 03:04:39

标签: java android connectivity unreachable-statement

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    return inflater.inflate(R.layout.item_recipe_list, container, false);

    ConnectivityManager connMgr =
            (ConnectivityManager)getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);

}

我在Fragment中编写代码,但它使错误无法访问语句

public void updateConnectedFlags() {
    ConnectivityManager connMgr =
            (ConnectivityManager)getActivity().getSystemService(Context.CONNECTIVITY_SERVICE);
}

所以,我在方法中移动代码,但没有错误。为什么呢?

0 个答案:

没有答案