@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View fa = getView(); ll = (LinearLayout)inflater.inflate(R.layout.chat_layout, container,false); layoutToast = (TextView)fa.findViewById(R.id.layoutToast); return ll; //return inflater.inflate(R.layout.chat_layout, container, false); if (!UtilChat.checkConnection(getActivity())){ UtilChat.initToast(getActivity(),"LOL", Toast.LENGTH_SHORT); // finish(); }else{ bindViews(); verificaUsuarioLogado(); mGoogleApiClient = new GoogleApiClient.Builder(getActivity()) .enableAutoManage(getActivity(), this) .addApi(Auth.GOOGLE_SIGN_IN_API) .build(); } } public class UtilChat { public static final String URL_STORAGE_REFERENCE = "gs://korenovskguide-99b08.appspot.com"; public static final String FOLDER_STORAGE_IMG = "image"; public static void initToast(Context c, String message){ Toast.makeText(c,message,Toast.LENGTH_SHORT).show(); } public static boolean checkConnection(Context context) { boolean connection; ConnectivityManager conectivtyManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); connection = conectivtyManager.getActiveNetworkInfo() != null && conectivtyManager.getActiveNetworkInfo().isAvailable() && conectivtyManager.getActiveNetworkInfo().isConnected(); return connection; } 

Problem c:

UtilChat.initToast (getActivity (), "LOL", Toast.LENGTH_SHORT);

Mistake:

Error: (125, 20) error: method initToast in class; required: Context, String found: FragmentActivity, String, int

    1 answer 1

    In your error, it is literally written that 2 parameters are expected with the types Context and String, and you pass Context, String and int.

    Those. just remove the last argument, i.e. do so:

     UtilChat.initToast(getActivity(), "LOL"); //а не так: //UtilChat.initToast(getActivity(), "LOL", Toast.LENGTH_SHORT); 
    • Error: (124, 9) error: unreachable statement Error: (136, 5) error: missing return statement Now there are such errors - Imperator
    • one
      @Imperator, you would read at least the first couple of chapters of any Java textbook before messing with Firebase) Transfer return ll; at the end of the method - your method now completes before the income before the code highlighted in red. This is a compilation error. - Yuriy SPb