Appodeal Rewarded ads failed to Load - android

Im solving this issue for about 3 days. Im implementing Rewarded Ads of Appodeal. When I first start my app It works fine . Appodeal onRewardedVideoLoaded function called and it works fine. But After closing the app and running it again. It always calls onRewardedVideoFailedToLoad function and ads do not load. Below is my code.
Please check this code. Thankyou
/** Set up button to show an ad when clicked */
show_button.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
//ad.show();
if (Appodeal.isLoaded(Appodeal.REWARDED_VIDEO)) {
Appodeal.show(getActivity(), Appodeal.REWARDED_VIDEO);
}
}
});
//appodeal
Appodeal.setAutoCache(Appodeal.REWARDED_VIDEO, false);
Appodeal.initialize(getActivity(), appKey, Appodeal.REWARDED_VIDEO);
// Appodeal.setTesting(true);
Appodeal.setLogLevel(com.appodeal.ads.utils.Log.LogLevel.verbose);
Appodeal.cache(getActivity(), Appodeal.REWARDED_VIDEO);
if (Appodeal.isLoaded(Appodeal.REWARDED_VIDEO)) {
progress.setVisibility(View.INVISIBLE);
System.out.println("Is loaded so enable");
show_button.setText("Earn Reward");
}
Appodeal.setRewardedVideoCallbacks(new RewardedVideoCallbacks() {
private Toast mToast;
#Override
public void onRewardedVideoLoaded() {
System.out.println("onRewardedVideoLoaded");
show_button.setEnabled(true);
progress.setVisibility(View.INVISIBLE);
show_button.setText("Earn Reward");
}
#Override
public void onRewardedVideoFailedToLoad() {
System.out.println("onRewardedVideoFailedToLoad");
progress.setVisibility(View.INVISIBLE);
}
#Override
public void onRewardedVideoShown() {
System.out.println("onRewardedVideoShown");
show_button.setEnabled(false);
show_button.setText("Not Avalible");
progress.setVisibility(View.VISIBLE);
}
#Override
public void onRewardedVideoFinished(int amount, String name) {
System.out.println(String.format("onRewardedVideoFinished. Reward: %d %s", amount, name));
SharedPref.putIntPref("rewards_count", SharedPref.getIntPref("rewards_count", getContext()) + amount, getContext());
// watcher.RemainingRewards(SharedPref.getIntPref("rewards_count", getContext()));
UpdateRewards();
}
#Override
public void onRewardedVideoClosed(boolean finished) {
System.out.println(String.format("onRewardedVideoClosed, finished: %s", finished));
}
void showToast(final String text) {
if (mToast == null) {
mToast = Toast.makeText(getActivity(), text, Toast.LENGTH_SHORT);
}
mToast.setText(text);
mToast.setDuration(Toast.LENGTH_SHORT);
mToast.show();
}
});
return view;
}

I had a similar issue, but actually it was connected with framework I used (it turned out after I contacted them), so I'd suggest asking their support directly, usually they respond rather quick + u can message them from LiveChat window on the homepage, right bottom corner. This would be the best way to solve your provlem imo. Not sure that my case will solve your problem, but still it might help you somehow.
i wanted to show skippable and non skippable videos in several projects.
All in all using skippable videos was simple, i only needed to implement GdxAppodeal.VIDEO while initializing.
so to show videos I used GdxAppodeal.getInstance().show(GdxAppodeal.VIDEO);
+
Video callbacks:
GdxAppodeal.getInstance().setVideoCallbacks(new VideoCallback() {
#Override
public void onVideoLoaded() { }
#Override
public void onVideoFailedToLoad() { }
#Override
public void onVideoShown() { }
#Override
public void onVideoFinished() { }
#Override
public void onVideoClosed() { }
});
important nuance was that u can't set reward settings on site for skippable video.
This only works for rev vids.
So, User will get reward on RewardedVideoFinished callback

Related

why is my admost interstitial ad not loading in android java?

I'm trying to do admost interstitial integration into my application. There are tab actions in my application, so there is bottom navigation at the bottom of the screen, and when they are clicked, interstitial should appear, at least I think I coded it that way, but it never loads because interstitial.isLoaded is null. interstitial does not come null activity , does not come null , but isLoaded does not show at all because it is always false . I'm sharing my codes can you help me with this I'm stuck here
I only share the necessary stuff because I have set up an abstract factory structure and it would be too complicated to share the whole structure
public void ifNeededShowinterstitial(){
if(UserConfig.enabledAds && UserConfig.enabledInterstitialAds){
DYTIntersitialProvider interstitial = DYTBannerFactory.shared().interstitial(DYTBannerFactory.shared().getBannerIdContainer().interstitial());
if(interstitial instanceof DYTBannerActivityClient){
((DYTBannerActivityClient) interstitial).setActivity(BaseActivity.mainActivity);
}
interstitial.load();
}
}
public void gotoExerciseActivity() {
behavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
Intent i = new Intent(MainActivity.this, ExerciseActivity.class);
i.addFlags(Intent.FLAG_FROM_BACKGROUND);
startActivity(i);
//overridePendingTransition(R.anim.slide_in_right, R.anim.slide_out_left);
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
ifNeededShowinterstitial();
}
For example, in this code, when the exercise button on the navigation bar is clicked, it calls the ifNeededShowinterstitial function at the bottom, which calls load.
AdMostInterstitial interstitial;
Activity activity;
#Override
public void setActivity(Activity activity) {
this.activity = activity;
}
#Override
public void load() {
if (interstitial == null) {
AdMostAdListener listener = new AdMostAdListener() {
#Override
public void onDismiss(String message) {
Log.d(Statics.TAG, "MainActivity interstitial onDismiss network: " + message);
}
#Override
public void onComplete(String s) {
Log.d(Statics.TAG, "MainActivity interstitial onComplete network: " + s);
}
#Override
public void onFail(int errorCode) {
logError(errorCode, "interstitial");
}
#Override
public void onReady(String network, int ecpm) {
Log.d(Statics.TAG, "MainActivity interstitial onReady network : " + network);
}
#Override
public void onShown(String network) {
Log.d(Statics.TAG, "MainActivity interstitial onShown network: " + network);
}
#Override
public void onClicked(String s) {
Log.d(Statics.TAG, "MainActivity interstitial onClicked network: " + s);
}
#Override
public void onStatusChanged(int i) {
}
};
interstitial = new AdMostInterstitial(this.activity, Statics.FULLSCREEN_ZONE, listener);
}
interstitial.refreshAd(false);
if(interstitial != null && interstitial.isLoaded())
interstitial.show();
}
Every time these navigation buttons are clicked, load is called and these codes work. I did the same codes in the documentation codes. What could be the problem? Is there something missing or am I doing something wrong I couldn't figure it out please help?
you can see it here in the documentation: https://admost.github.io/amrandroid/

Android vungle event listener

I'm having a problem with vungle, I want the dialog fragment to appear after the video ad ends, my code looks good and there is no errors, the video starts and ends but my dialog fragment never appears, here is my code:
private final EventListener vungleListener = new EventListener(){
#Override
public void onVideoView(boolean isCompletedView, int watchedMillis, int videoDurationMillis) {
if (isCompletedView){
frag.show(fm, "");
}
}
#Override
public void onAdStart() {
// Called before playing an ad
}
#Override
public void onAdEnd(boolean wasCallToActionClicked) {
}
#Override
public void onAdPlayableChanged(boolean isAdPlayable) {
}
#Override
public void onAdUnavailable(String reason) {
}
};
According to Vungle the method onVideoView is deprecated and the method onAdEnd should be used instead. You should try moving the fragment being shown to onAdEnd like below:
#Override
public void onAdEnd(boolean wasCallToActionClicked) {
frag.show(fm, "");
}

rx-android (or rx-java) with refreshlayout

I'm using a swiperefreshlayout android.support.v4.widget.SwipeRefreshLayout, and using rxjava to query to server every time a swipe happens. My code is like below, I have to create duplicate observable and subscriber inside the OnRefreshListener for them to get called, which looks quite bad due to code duplication. If I use the original ones (declared outside), then the subscriber is never returned (no onNext, onError, onCompleted triggered). What am I missing with RxJava in this case?
Subscriber<ListVerifyResponseWrapper> subscriber = new Subscriber<ListVerifyResponseWrapper>() {
#Override
public void onCompleted() {
LogUtils.LOGD(TAG, "completed");
}
#Override
public void onError(Throwable e) {
Toast.makeText(getActivity(), getString(R.string.An_error_has_occured), Toast.LENGTH_SHORT).show();
mSwipeRefreshLayout.setRefreshing(false);
}
#Override
public void onNext(ListVerifyResponseWrapper listVerifyResponseWrapper) {
changeViewStateAccordingToResult(listVerifyResponseWrapper);
}
};
mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
#Override
public void onRefresh() {
Observable<ListVerifyResponseWrapper> observableDuplicate = RestClient.getInstance().getRestApi().getListVerifyRequestDetail(model);
final Subscriber<ListVerifyResponseWrapper> subscriberDuplicate = new Subscriber<ListVerifyResponseWrapper>() {
#Override
public void onCompleted() {
LogUtils.LOGD(TAG, "completed");
}
#Override
public void onError(Throwable e) {
Toast.makeText(getActivity(), getString(R.string.An_error_has_occured), Toast.LENGTH_SHORT).show();
mSwipeRefreshLayout.setRefreshing(false);
}
#Override
public void onNext(ListVerifyResponseWrapper listVerifyResponseWrapper) {
changeViewStateAccordingToResult(listVerifyResponseWrapper);
}
};
observableDuplicate.observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.newThread()).subscribe(subscriberDuplicate);
}
});
observable.observeOn(AndroidSchedulers.mainThread()).subscribeOn(Schedulers.newThread()).subscribe(subscriber);
Thanks
I had the exact same problem. I solved it by chaining
.observeOn(AndroidSchedulers.mainThread())
right before the final subscriber. Apparently you have to make sure that stuff concerning the UI is done on the UI thread
On top of Johnnycube's answer (which is correct), I suggest you to use
subscribeOn(Schedulers.io())
which is meant for processing callbacks, amongst other things.

What to change in my app (no AD within it) to avoid violation of the YouTube API Terms of Service?

I have a basic app for kids that allows them to click on icon to perform a youtube search (link to amazon app store).
Although I have done a lot of changes in the app, its removed from the Google Play store for "violation of the YouTube Terms of Service or YouTube API Terms of Service" (the full text is attached below).
I did a research here and it seems that my app dosen't have the problems that i have seen in other applications. the app dosen't have AD's and i think its not interfiring to the youtube Ad's and not playing videos in background.
In addition, I filed an appeal to Google Play. Their response was that my app streams copyrighted content from YouTube. I had a search for cartoons, so i removed it and resubmited and the app rejected again for the same reason.
when i asked for further assistance they answer: "Unfortunately, as much as we'd like to help, we aren't able to provide additional information for your inquiry".Very frustrating.
I'd appreciate your help. Perhaps i made a mistake in the code that implements the YoutubePlayer, Other ideas are welcome to.
the full Notification from Google Play:
This is a notification that your application, KidoTube, for package ID com.elelad.kidstube, has been removed from Google Play.
Please address the issue described below and submit a compliant update. Once approved, your application will again be available with all installs, ratings and reviews intact.
REASON FOR REMOVAL:Violation of section 4.4 of the Developer Distribution Agreement.
After a regular review, we have determined that your app downloads, monetizes, or otherwise accesses YouTube videos in violation of the YouTube Terms of Service or YouTube API Terms of Service. Accessing content, a product, or service in an unauthorized manner is a violation of the Developer Distribution Agreement, and is not allowed on Google Play.
All removals are tracked. Repeated removals will result in app suspension, at which point this app will count as a strike against the good standing of your developer account and no longer be available on Google Play.
This notification also serves as notice for other apps in your catalog. You can avoid future removals and/or app suspensions by immediately ensuring that no other apps in your catalog are in violation of (but not limited to) the above policy. Before publishing applications, please ensure your apps’ compliance with the Developer Distribution Agreement and Content Policy.
If you feel we have made this determination in error, you can visit this Google Play Help Center article.
The Google Play Team
My YoutubeActivity Class:
public class YoutubeActivity extends YouTubeBaseActivity implements YouTubePlayer.OnInitializedListener {
private final static String TAG = YoutubeActivity.class.getSimpleName();
YouTubePlayer player;
public static String YOUTUBE_VIDEO_ID = null;
LayoutInflater mLayoutInflater;
private FragmentActivity myContext;
public TextView textToast;
public View toastLayout;
ProgressBar cycleProgressBar;
Search search = new Search();
List<Video> mVideoList;
private static boolean initialize = false;
GetRandomInBackground getRandomInBackground;
YouTubePlayerView youTubePlayer;
ImageView waitLogo;
AnimationDrawable frameAnimation2;
ImageButton play;
public static void setYoutubeVideoId(String youtubeVideoId) {
YOUTUBE_VIDEO_ID = youtubeVideoId;
}
#Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
if (hasFocus) {
getWindow().getDecorView().setSystemUiVisibility(
View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_FULLSCREEN
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);}
}
#Override
public void onCreate(Bundle savedInstanseState) {
super.onCreate(savedInstanseState);
ContentResolver mContentResolver = getContentResolver();
setContentView(R.layout.youtube_player);
waitLogo = (ImageView) findViewById(R.id.player_logo);
play = (ImageButton) findViewById(R.id.play);
try {
startLogoAnimation();
}catch (Exception e){
waitLogo.setImageResource(R.mipmap.kidotube);
}
youTubePlayer = (YouTubePlayerView) findViewById(R.id.vYouTubePlayer);
if (Setting.isStartRandomVideo()) {
getRandomInBackground = new GetRandomInBackground();
getRandomInBackground.execute();
}
youTubePlayer.initialize(Search.getGoogleApiKey(), this);
youTubePlayer.setVisibility(View.INVISIBLE);
}
#Override
protected void onPause() {
super.onPause();
BaseActivity.myLifecycleHandler.onActivityPaused(this);
}
#Override
protected void onResume() {
super.onResume();
BaseActivity.myLifecycleHandler.onActivityResumed(this);
}
#Override
public void onInitializationFailure(YouTubePlayer.Provider provider,
YouTubeInitializationResult result) {
Toast.makeText(this, "Cant initialize YouTube Player", Toast.LENGTH_LONG).show();
finish();
}
#Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer mplayer,
boolean wasRestored) {
this.player = mplayer;
player.setPlayerStyle(YouTubePlayer.PlayerStyle.CHROMELESS);
player.setPlayerStateChangeListener(playerStateChanageListener);
player.setPlaybackEventListener(playBackEvaentListener);
if (!Setting.isStartRandomVideo()) {
player.loadVideo(YOUTUBE_VIDEO_ID);
}
}
private YouTubePlayer.PlaybackEventListener playBackEvaentListener = new YouTubePlayer.PlaybackEventListener() {
public void onBuffering(boolean arg0) {
Log.v(TAG, "onBuffering");
}
#Override
public void onPaused() {
Log.v(TAG, "onPaused");
}
#Override
public void onPlaying() {
Log.v(TAG, "onPlaying");
}
#Override
public void onSeekTo(int arg0) {
Log.v(TAG, "onSeekTo");
}
#Override
public void onStopped() {
Log.v(TAG, "onStopped");
}
};
private YouTubePlayer.PlayerStateChangeListener playerStateChanageListener = new YouTubePlayer.PlayerStateChangeListener() {
#Override
public void onAdStarted() {
}
#Override
public void onError(YouTubePlayer.ErrorReason arg0) {
Log.v(TAG, "onError" );
Toast.makeText(YoutubeActivity.this, getString(R.string.Video_Error), Toast.LENGTH_LONG).show();
finish();
}
#Override
public void onLoaded(String arg0) {
Log.v(TAG, "onLoaded" + arg0);
}
#Override
public void onLoading() {
Log.v(TAG, "onLoading" );
}
#Override
public void onVideoEnded() {
Log.v(TAG, "onVideoEnded" );
finish();
}
#Override
public void onVideoStarted() {
Log.v(TAG, "onVideoStarted");
play.setVisibility(View.INVISIBLE);
waitLogo.setVisibility(View.INVISIBLE);
frameAnimation2.stop();
youTubePlayer.setVisibility(View.VISIBLE);
}
};
public class GetRandomInBackground extends AsyncTask<Void, Void, Void> {
#Override
protected Void doInBackground(Void... params) {
search.SearchNow(MainActivity.getSearchFor());
return null;
}
#Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
try {
if (search.getVideoList() == null || search.getVideoList().size() == 0) {
Toast.makeText(YoutubeActivity.this, getString(R.string.No_results_found), Toast.LENGTH_LONG).show();
Intent intent = new Intent(YoutubeActivity.this, MainActivity.class);
startActivity(intent);
} else {
mVideoList = search.getVideoList();
setYoutubeVideoId(search.playRand(mVideoList));
player.loadVideo(YOUTUBE_VIDEO_ID);
Search.setNumberOfVideosReturned(20);
}
}catch (Exception e){
finish();
}
}
}
public void startLogoAnimation(){
waitLogo.setBackgroundResource(R.drawable.wait_icon);
frameAnimation2 = (AnimationDrawable) waitLogo
.getBackground();
frameAnimation2.start();
}
public int animationDuration(AnimationDrawable animationDrawable){
int duration = 0;
int frames = animationDrawable.getNumberOfFrames();
for (int i = 0; i<frames; i++){
duration = duration + animationDrawable.getDuration(i);
}
return duration;
}
Thanks in advance!
well, it was one of my settings.
I made an option to click on icon and play a random video, apparently it's violation of the API terms.
When I removed the option the application is approved.
I hope this is the end..

Android: Avoid opening the dialog several times, but allow hide and shows the same dialog

I have an Activity with ViewPager PagerSlidingTabStrip for each page of my ViewPager has a fragment, and in each fragment realize an http request (using Volley) to load the data from the page, but when the request ends in error, type timeout or lost connection, I need to display a dialog with the option to redo the call to the server, the problem to prevent multiple dialogs are open for each error is resolved with the snippet:
See this solution here: http://www.jorgecoca.com/android-quick-tip-avoid-opening-multiple-dialogs-when-tapping-an-element/
#Override
public void show(FragmentManager manager, String tag) {
if (manager.findFragmentByTag(tag) == null) {
super.show(manager, tag);
}
}
When the user clicks the dialog button to try again, and the dialog closed and taken to check if there is internet connection, if I'm not, the dialog should be opened again, but the dialog is not displayed again, I believe that the tag does not was released to FragmentManager.
Code in Activity:
final Button mButton = ( Button ) this.findViewById( R.id.btn_opendialog );
final DialogFragmentHelper mDialog = new DialogFragmentHelper();
mDialog.setCallbackListener( new OnCallback() {
#Override
public void onCancel() {
}
#Override
public void onConfirm() {
// verify if network available
mDialog.show( MainActivity.this.getSupportFragmentManager(), DialogFragmentHelper.DIALOG_TAG );
}
} );
mButton.setOnClickListener( new OnClickListener() {
#Override
public void onClick( final View v ) {
mDialog.show( MainActivity.this.getSupportFragmentManager(), DialogFragmentHelper.DIALOG_TAG );
}
} );
Would someone have a suggestion of a workaround?
In order to maintain the structure that is ready in my project, and also keep something closer to my goal, which is to use no flags, nor pass control of a third dialogfragment to manage, arrived at a solution that'll take an hour as a result.
DialogFragmentHelper mDialog = new DialogFragmentHelper();
mDialog.setCallbackListener( new OnCallback() {
#Override
public void onCancel() {}
#Override
public void onConfirm() {
mDialog.dismissAllowingStateLoss();
if(networkAvailable == false){
new Handler().post( new Runnable() {
#Override
public void run() {
mDialog.show( MainActivity.this.getSupportFragmentManager(), DialogFragmentHelper.DIALOG_TAG );
}
} );
}else {
//do something here
}
}
} );
this way I guarantee that while several requests are sent to open the dialogfragment, only the first is executed, and closing the dialogfragment, I can quickly open it again if needed, as can happen in the scenario I'm working.
You could approach it with a singleton controller. E.g.:
package com.example.stackoverflowsandbox;
public class MyDialogController {
private static MyDialogController instance;
public static MyDialogController getInstance() {
if ( MyDialogController.instance == null ) {
MyDialogController.instance = new MyDialogController();
}
return MyDialogController.instance;
}
private boolean dialogOpenned;
private MyDialogController() {}
public void closeDialog() {
if ( this.dialogOpenned ) {
this.dialogOpenned = false;
// you close code...
}
}
public void openDialog() {
if ( !this.dialogOpenned ) {
this.dialogOpenned = true;
// your open code...
}
}
}

Categories

Resources