Unity Ads are displaying continuously in my Android App - android

I have an Android app developed in Android Studio. And I have integrated Unity Ads in my app showing full-screen video Ads.
I have followed each step carefully in their documentation:
https://unityads.unity3d.com/help/monetization/integration-guide-android
But the ads are displaying continuously one after another. There is no stopping for this video ads. I am losing users for my app because of this.
Here is my implementation according to their docs in MainActivity.class:
UnityListener unityListener = new UnityListener();
UnityAds.initialize(MainActivity.this, "my_ad_unit_id", unityListener);
private class UnityListener implements IUnityAdsListener {
#Override
public void onUnityAdsReady(String s) {
UnityAds.show(MainActivity.this);
}
#Override
public void onUnityAdsStart(String s) {
}
#Override
public void onUnityAdsFinish(String s, UnityAds.FinishState finishState) {
}
#Override
public void onUnityAdsError(UnityAds.UnityAdsError unityAdsError, String s) {
}
}

Related

AppLovin unable to precache resources

I want to use AppLovin Native Ads in my application. I did these
AppLovinSdk.initializeSdk(getContext());
AppLovinSdk sdk = AppLovinSdk.getInstance(getContext());
AppLovinNativeAdService nativeAdService = sdk.getNativeAdService();
nativeAdService.loadNativeAds(3, new AppLovinNativeAdLoadListener() {
#Override
public void onNativeAdsLoaded(List<AppLovinNativeAd> list) {
getActivity().runOnUiThread(() -> {
presenter.onApplovinNativeAdsLoaded(list);
});
}
#Override
public void onNativeAdsFailedToLoad(int i) {
presenter.onApplovinNativeAdsFailedToLoad();
}
});
However, I get error code -200 which is UNABLE_TO_PRECACHE_RESOURCES. I added android.permission.WRITE_EXTERNAL_STORAGE permission to manifest. And I did everything the same as in the official tutorial but I still get this error. What can be the cause?

zxing qr code scanner camera showing white screen

Good day! i'm having an issue with the qr code scanner in android marshmallow and nougat using the library that i have added as dependency in my project the camera shows white screen. Code runs perfectly in lollipop and kitkat. Please let me know if there was something i have missed or something i will do to make it work. I have paste my snippets of code down below. It is my pleasure if you give me some time to notice my concern. I have seen similar topic of my issue but it did not help me work out or i have implemented it wrong. Thank you in advance.
I have zxing jar library for generating qr code, and i used me.dm7.barcodescanner:zxing:1.8.4 for scanning qr codes:
dependency {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/zxing-2.1.jar')
compile('me.dm7.barcodescanner:zxing:1.8.4'){
exclude group: 'com.google.zxing'
}
}
The Activity for the opening of the camera:
public class ScanQRCodeActivity extends AppCompatActivity implements ZXingScannerView.ResultHandler {
private String strDataEncrypted;
private ZXingScannerView mScannerView;
public static String strEncrypt;
public static String strEncrypted;
public static String strIV;
public static boolean isScanSuccess = false;
#Override
public void onCreate(Bundle state) {
super.onCreate(state);
mScannerView = new ZXingScannerView(this);
setContentView(mScannerView);
}
#Override
public void onResume() {
super.onResume();
mScannerView.setResultHandler(this);
mScannerView.startCamera();
}
#Override
public void onPause() {
super.onPause();
mScannerView.stopCamera();
}
#Override
public void handleResult(Result result) {
strDataEncrypted = result.getText();
Log.wtf("handleResult", strDataEncrypted);
String[] strSplit = strDataEncrypted.split("\\|\\|");
strEncrypted = strSplit[0].trim();
strIV = strSplit[1];
CryptLibHelper cryptLibHelper = new CryptLibHelper();
cryptLibHelper.decrypt(strEncrypted, strIV, new CryptLibHelper.CryptLibDecryptCallback() {
#Override
public void onDecryptFailed(String str_message) {
Log.wtf("onDecryptFailed", str_message);
}
#Override
public void onDecryptSuccess(String str_message) {
if (str_message.contains("}")) {
strEncrypt = str_message.replace("}", "");
Log.wtf("onDecryptSuccess", strEncrypt);
}
}
});
onBackPressed();
isScanSuccess = true;
mScannerView.resumeCameraPreview(this);
}
}
Have you added CAMERA permission check in your app?? Since from marshmallow onwards you need to ask user for some permissions.
You can first try to manually give permission to your app from device settings.
I was experiencing this issue on and off, my problem was that my application was requesting camera permissions too late! Make sure your application is requesting the camera permissions BEFORE an instance of ZXing qr scanner is created.

Gdx.input.justTouched() is not working on all devices

I am developing a game in LibGdx for android device. I could see a strange issue in using Gdx.input.justTouched(). It is working in some device and not in some device. Could you please help me if my code needs any correction?
#Override
public void create() {
Gdx.input.setInputProcessor(this);
Gdx.input.setCatchBackKey(true);
}
public void render(SpriteBatch sb) {
if (Gdx.input.justTouched()){
System.out.println("inside : " );
dragNew = new Vector2(Gdx.input.getX(), Gdx.input.getY());
dragOld = dragNew;
}
}

ConnectSDK Android

Working with connectSDK Android for casting videos on samsung android Tv.
I've successfully launch the default youtube app and played as well.
But when ever i'm trying to stop the currently running Youtube video getting a response code = 400 i.e
com.connectsdk.service.command.ServiceCommandError: Bad Request
Anyone worked on this? or familiar with the issue?
Code:
if (runningAppSession != null) {
if (runningAppSession.getSessionType() == LaunchSessionType.App) {
getLauncher().closeApp(runningAppSession, new ResponseListener<Object>() {
#Override
public void onError(ServiceCommandError error) {
System.out.println(error);
}
#Override
public void onSuccess(Object object) {
System.out.println(object.toString());
}
});
}
}

How to play youtube video using Youtube Data api v3 Android?

Few days back I asked question Youtube API v2 not supported So as per youtube they have deprecated and all application and websites using this v2 api wont work at all. As they told to migrate to v3 there are any good example or documents for android. I have youtube url with video id. I just want to play videos using this api
You can use Video ID to play video...
Use YouTubePlayerView for that...
Let me show you a example which will makes everything clear....
below is a class which contains a YouTubePlayerView..
public class Play_youtube_video extends YouTubeBaseActivity implements YouTubePlayer.OnInitializedListener
{
YouTubePlayerView video_player;
public static String VIDEO_ID = "";
#Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// HIDE THE KEYBOARD
getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
// TITLE BAR DISABLES AND FULL SCREEN IMPLEMENTATION
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_play_youtube_video);
try
{
System.out.println("youtube----VIDEO_ID---->" + VIDEO_ID);
video_player = (YouTubePlayerView) findViewById(R.id.youtubeplayerview_full_screen);
video_player.initialize(GlobalConstant.YOUTUBE_APIKEY, Play_youtube_video.this);
}
catch(Exception e)
{
e.printStackTrace();
}
catch(OutOfMemoryError e)
{
e.printStackTrace();
}
}
#Override
public void onInitializationFailure(Provider provider, YouTubeInitializationResult result)
{
GlobalUtills.showToast("Youtube player not found.", Play_youtube_video.this);
}
#Override
public void onInitializationSuccess(Provider provider, YouTubePlayer player, boolean wasRestored)
{
if( !wasRestored )
{
player.loadVideo(Youtube_VIDEO_ID);
// player.setFullscreen(true);
// player.play();
}
}
public void closeYoutube(View v)
{
Play_youtube_video.this.finish();
}
}
I am answering this question because after some frustration it was not on android api related issue but Gdata youtube api i was using was returning wrong results.
Now its fixed.

Categories

Resources