0

Could guys hep me integrate Startapp network in this activity, this is my code it has not the oncreate method i tried to integrate it but i failed. Please help me. You can find below the code and it does not contain the oncreate method.Im new to coding and i tried lot of time to solve this problem it's easy for me if the oncreate method is there i can integrate the ad network easy. Pleas guys any idea to deal with will help me. Thank you

public class MainFragment extends Fragment {

    public MainFragment() {
        // Required empty public constructor
    }

    private final String TAG = "MainFragment";
    Activity activity;
    AdView bannerAdView;
    boolean isAdLoaded;
    CardView cardVideoToGIF, cardImagesToGIF, cardCaptureImage, cardVideoToAudio, cardVideoCutter, cardGallery;
    LinearLayout linearRow2;

    private String SELECTED_TYPE = Constants.TYPE_GIF;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_main, container, false);
    }

    @Override
    public void onResume() {
        super.onResume();
        if (bannerAdView != null) {
            bannerAdView.resume();
        }
        ((MainActivity) activity).setTitle("");
        ((MainActivity) activity).setDrawerState(true);

        if (!MyApplication.isFFmpegSupports) {
            linearRow2.setVisibility(View.GONE);
        }
    }

    @Override
    public void onPause() {
        if (bannerAdView != null) {
            bannerAdView.pause();
        }
        super.onPause();
    }

    @Override
    public void onDestroy() {
        if (bannerAdView != null) {
            bannerAdView.destroy();
        }
        super.onDestroy();
    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        initViews(view);

        cardVideoToGIF.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                showPopupMenu(cardVideoToGIF);
                SELECTED_TYPE = Constants.TYPE_GIF;
            }
        });
Phantômaxx
  • 37,901
  • 21
  • 84
  • 115

1 Answers1

0

Replace your code with the following

public class MainFragment extends Fragment {

 // Add these lines of code which is the onCreate method of your Fragment
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);

         // put your integration code here
        Log.i("MainFragment", "onCreate()");
     }

public MainFragment() {
    // Required empty public constructor
}

private final String TAG = "MainFragment";
Activity activity;
AdView bannerAdView;
boolean isAdLoaded;
CardView cardVideoToGIF, cardImagesToGIF, cardCaptureImage, cardVideoToAudio, cardVideoCutter, cardGallery;
LinearLayout linearRow2;

private String SELECTED_TYPE = Constants.TYPE_GIF;

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
                         Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    return inflater.inflate(R.layout.fragment_main, container, false);
}

@Override
public void onResume() {
    super.onResume();
    if (bannerAdView != null) {
        bannerAdView.resume();
    }
    ((MainActivity) activity).setTitle("");
    ((MainActivity) activity).setDrawerState(true);

    if (!MyApplication.isFFmpegSupports) {
        linearRow2.setVisibility(View.GONE);
    }
}

@Override
public void onPause() {
    if (bannerAdView != null) {
        bannerAdView.pause();
    }
    super.onPause();
}

@Override
public void onDestroy() {
    if (bannerAdView != null) {
        bannerAdView.destroy();
    }
    super.onDestroy();
}

@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    initViews(view);

    cardVideoToGIF.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            showPopupMenu(cardVideoToGIF);
            SELECTED_TYPE = Constants.TYPE_GIF;
        }
    });
amit
  • 709
  • 6
  • 17
  • It's working but i got a problem with StartAppSDK.init(this, "206132687", true); i got a red line under (this, "206132687", true) and a message saying: Cannot resolve method'init(com.elsner.VideoConverter.fragments.MainFragment,java.lang.String,boolean)' . Is there a way to solve this problem? Thank you so much for helping me – Laamoud Jul 11 '18 at 15:52
  • `StartAppSDK.init(this, "206132687", true);` error coz you have put string value "206132687" and are setting it as a `boolean` value – amit Jul 11 '18 at 16:10
  • add this to your MainFragment. java `Boolean b = Boolean.valueOf("206132687");` and replace `StartAppSDK.init(this, "206132687", true);` with `StartAppSDK.init(this, b, true);` – amit Jul 11 '18 at 16:13
  • for more details refer this [link](https://stackoverflow.com/questions/1538755/how-to-convert-string-object-to-boolean-object) – amit Jul 11 '18 at 16:16
  • I always get the same error, this is my new code please check it and thank you for your time. public class MainFragment extends Fragment { // Add these lines of code which is the onCreate method of your Fragment Boolean b = Boolean.valueOf("206132687"); @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // put your integration code here StartAppSDK.init(this, b, true); Log.i("MainFragment", "onCreate()"); } – Laamoud Jul 11 '18 at 19:19
  • update your full `MainFragment.java class` which has the lines `StartAppSDK.init(this, "206132687", true);` on which you are getting the error... – amit Jul 13 '18 at 09:04