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, "");
}
Related
I hope you can help me, I am starting with UnityAds, I have an application on Android Studio (Java) where the SplashActivity has a button.
What I want is that, after pressing the button, the UnityAds interstitial is shown and when the ad ends, the MainActivity is shown.
The code I made shows the interstitial after the button but I don't know how to make it open the next activity to the MainActivity because after the interstitial it returns to the SplashActivity
public class SplashActivity extends AppCompatActivity {
String GameID = "123456";
String adUnitId = "Interstitial";
Boolean TestMode = true;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_intro_uno);
//iniciador Unity
UnityAds.initialize(SplashActivity.this, GameID, TestMode, new IUnityAdsInitializationListener() {
#Override
public void onInitializationComplete() {
}
#Override
public void onInitializationFailed(UnityAds.UnityAdsInitializationError unityAdsInitializationError, String s) {
}
});
//iniciador Unity
}
public void onClick(View view) {
IUnityAdsShowListener iUnityAdsShowListener = new IUnityAdsShowListener() {
#Override
public void onUnityAdsShowFailure(String s, UnityAds.UnityAdsShowError unityAdsShowError, String s1) {
}
#Override
public void onUnityAdsShowStart(String s) {
UnityAds.load(adUnitId);
UnityAds.show(SplashActivity.this,adUnitId);
}
#Override
public void onUnityAdsShowClick(String s) {
}
#Override
public void onUnityAdsShowComplete(String s, UnityAds.UnityAdsShowCompletionState unityAdsShowCompletionState) {
}
};
UnityAds.load(adUnitId);
UnityAds.show(SplashActivity.this,adUnitId);
}
}
Just add
startActivity(new Intent(MainActivity.this,MainActivity2.class));
In onUnityAdsShowComplete method
---In this above line MainActivity is the Current Activity and MainActivity2 is the second Activity
So, I'm using version Mapbox Navigation 0.3.1, I'm fetching route from private OSRM server. Snap-to-route and other features are just working fine, however when 1st step finishes navigation wouldn't proceed to the next step and offRoute method is being called. I'm stuck here for like 1-2 months. I would appreciate any help.
Below, my code snippet of Mapbox Navigation implementation.
public class MapActivity implements MapboxMap.OnMarkerClickListener
,OnMapReadyCallback, AlertLevelChangeListener, ProgressChangeListener, OffRouteListener
,NavigationEventListener, LocationEngineListener{
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
fabStartNavigation.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
// star Navigation
startNavigation();
}
});
}
#Override
protected void onDestroy() {
super.onDestroy();
// Remove all navigation listeners being used
mNavigation.removeNavigationEventListener(this);
mNavigation.removeAlertLevelChangeListener(this);
mNavigation.removeProgressChangeListener(this);
mNavigation.removeOffRouteListener(this);
// End the navigation session
mNavigation.endNavigation();
mapView.onDestroy();
}
//navigation controller
private void startNavigation(){
mNavigation.addNavigationEventListener(this);
mNavigation.addAlertLevelChangeListener(this);
mNavigation.addOffRouteListener(this);
mNavigation.addProgressChangeListener(this);
mNavigation.setSnapToRoute(true);
/*LocationEngine mLocationEngine = LostLocationEngine.getLocationEngine(this);
// mNavigation.setLocationEngine(mLocationEngine);*/
mLocationEngine = LostLocationEngine.getLocationEngine(this);
mLocationEngine.setPriority(LocationEnginePriority.HIGH_ACCURACY);
mLocationEngine.addLocationEngineListener(this);
mLocationEngine.activate();
mNavigation.startNavigation(mPlannedRoute);
}
// navigation listeners
#Override
public void onAlertLevelChange(int alertLevel, RouteProgress routeProgress) {
switch (alertLevel) {
case HIGH_ALERT_LEVEL:
break;
case MEDIUM_ALERT_LEVEL:
break;
case LOW_ALERT_LEVEL:
break;
case ARRIVE_ALERT_LEVEL:
break;
case NONE_ALERT_LEVEL:
break;
case DEPART_ALERT_LEVEL:
break;
}
}
#Override
public void onProgressChange(Location location, RouteProgress routeProgress) {
}
#Override
public void userOffRoute(Location location) {
}
#Override
public void onRunning(boolean running) {
}
#Override
public void onConnected() {
mNavigation.setLocationEngine(mLocationEngine);
mLocationEngine.requestLocationUpdates();
}
#Override
public void onLocationChanged(Location location) {
}
}
This sounds like your running into a really old bug that has since been fixed. My advice would be to either upgrade to 0.4.0 or the 0.5.0-snapshot.
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
My fragment is
public class sample extends Fragment implements statusChanger{
void onResume() {
Listener.registerListener(this);
}
void onPause() {
Listener.deRegisterListener(this);
}
#Override
public void onStatusChanged() {
MyTextView.setVisibility(View.VISIBLE);
}
}
My Interface is
public interface StatusChanger {
void onStatusChanged();
}
My callback from another java class is
public void onstatusChanged() {
listener.onStatusChanged();
}
The above is the outline of my code , I could get a call back from the ordinal java class to my fragment , but the textView is not set to visible and i do not get any runtime errors.
Looks like it might be a thread issue. What if you run the onStatusChanged() code on the UI thread?
#Override
public void onStatusChanged() {
getActivity().runOnUiThread(new Runnable() {
#Override
public void run() {
MyTextView.setVisibility(View.VISIBLE);
}
});
}
In normal cases, following code will work:
getActivity().runOnUiThread(new Runnable() {
#Override
public void run() {
// Update UI here.
}
});
Note: If you have wrap above code with Handler with a delay then it may not work.
I would like to show banners in a fragment instead of an activity, how can I do this?
My Fragment:
Variables:
RevMob revmob;
Activity currentActivity;
Functions:
My Code:
public void startRevMobSession(){
currentActivity = this;
revmob = RevMob.startWithListener(currentActivity, new RevMobAdsListener() {
#Override public void onRevMobSessionStarted() {loadBanner();}
#Override public void onRevMobSessionNotStarted(String message) {}});
}
public void loadBanner() {
revmob.showBanner(currentActivity, Gravity.BOTTOM, null, new RevMobAdsListener() {
#Override public void onRevMobAdReceived() {}
#Override public void onRevMobAdNotReceived(String message) {}
#Override public void onRevMobAdDismissed() {}
#Override public void onRevMobAdClicked() {}
#Override public void onRevMobAdDisplayed() {}});
}
onCreate:
startRevMobSession();
It's working when I'm using it in an activity, but I would like to use it in a fragment. How can I do so?
In a fragment you should do:
currentActivity = getActivity();
instead of
currentActivity = this;
That's the only difference, it should all work properly then.