【问题标题】:startapp ads not workingstartapp 广告不起作用
【发布时间】:2018-07-11 08:41:28
【问题描述】:

大家能帮我在这个活动中集成 Startapp 网络吗,这是我的代码,它没有我尝试集成它的 oncreate 方法,但我失败了。请帮我。你可以在下面找到代码,它不包含 oncreate 方法。我是编码新手,我尝试了很多时间来解决这个问题,如果有 oncreate 方法对我来说很容易,我可以轻松集成广告网络。请大家处理任何想法都会帮助我。谢谢

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

【问题讨论】:

    标签: java android android-fragments startapp


    【解决方案1】:

    用以下代码替换您的代码

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

    【讨论】:

    • 它正在工作,但我遇到了 StartAppSDK.init 问题(this, "206132687", true);我在 (this, "206132687", true) 下看到一条红线,并显示一条消息:无法解析 method'init(com.elsner.VideoConverter.fragments.MainFragment,java.lang.String,boolean)' 。有没有办法解决这个问题?非常感谢你帮助我
    • StartAppSDK.init(this, "206132687", true); 错误,因为您已输入字符串值“206132687”并将其设置为boolean
    • 将此添加到您的 MainFragment。 java Boolean b = Boolean.valueOf("206132687"); 并将 StartAppSDK.init(this, "206132687", true); 替换为 StartAppSDK.init(this, b, true);
    • 更多详情请参考link
    • 我总是遇到同样的错误,这是我的新代码,请检查并感谢您的宝贵时间。 public class MainFragment extends Fragment { // 添加这些代码行,即 Fragment 的 onCreate 方法 Boolean b = Boolean.valueOf("206132687"); @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // 把你的集成代码放在这里 StartAppSDK.init(this, b, true); Log.i("MainFragment", "onCreate()"); }
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-04-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多