How do you get an index to a copy of the activate or fragment from another class?



  • In fact, the point is in the headline. I would like an example, thank you in advance.



  • I don't know what you want. If the method is to be applied from any place, the NAMA:

    Challenge:

    ActionIntentUtil.CallPhone(activity, "8805000000"); 
    

    ActionIntentUtil - class name of method

    Where? activity use this((имя активности) getActivity())getActivity()view.getContext()

    Method itself:

    public static void CallPhone(Context context, String number) {
        try {
            Uri address = Uri.parse("tel:"+number);
            Intent openlink = new Intent(Intent.ACTION_VIEW, address);
            context.startActivity(openlink);
        } catch (Exception e) {
            Toast.makeText(context, apps, Toast.LENGTH_LONG).show();e.printStackTrace();
        }
    }
    

    If it causes the same class where the method can be removed static and ActionIntentUtil




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2