简体   繁体   English

startapp广告无法正常工作

[英]startapp ads not working

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. 可以帮助我在此活动中集成Startapp网络,这是我的代码,它没有我尝试集成的oncreate方法,但失败了。 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. 您可以在下面的代码中找到,它不包含oncreate方法。我是编码的新手,我花了很多时间解决此问题,如果oncreate方法在那里,我可以轻松集成广告网络,这对我来说很容易。 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;
            }
        });

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;
        }
    });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM