Cannot show video ads from Smaato Ads for my Android App - android

I am trying to implement Smaato Video Ads on my Android App.
I have followed the instructions from the Smaato page and the Smaato example app and yet, I cannot manage to show the Smaato Video Ads.
The code that apparently should show a video ad in fullscreen is:
private static Video smaatoVideoAd; // A Smaato Video global variable
smaatoVideoAd = new Video(this.getApplicationContext());
smaatoVideoAd.getAdSettings().setPublisherId(0); //int of 0 is supposedly a test mode
//smaatoVideoAd.getAdSettings().setPublisherId(PublisherID);
smaatoVideoAd.getAdSettings().setAdspaceId(0); //int of 0 is supposedly a test mode
//smaatoVideoAd.getAdSettings().setAdspaceId(VideoAd_ID);
smaatoVideoAd.setVastAdListener(this);
smaatoVideoAd.setAutoCloseDuration(5);
smaatoVideoAd.disableAutoClose(true);
smaatoVideoAd.setVideoSkipInterval(3);
} // End of onCreate
// Called when the video has been loaded.
#Override
public void onReadyToShow() {
// Call this when you want to show the video ad.
smaatoVideoAd.show();
}
#Override
public void onWillShow() {
// Called when the ad will show.
}
#Override
public void onWillOpenLandingPage() {
// Called when the banner has been clicked.
}
#Override
public void onWillClose() {
// Called when Interstitial ad will be closed.
}
#Override
public void onFailedToLoadAd() {
// called when video failed to load.
}
The Smaato libs for build.gradle has been setup, and that is pretty straightforward and short:
repositories {
...
flatDir {
dirs 'libs'
}
...
}
dependencies {
...
implementation name:'SOMAAndroid-9.1.3-release', ext:'aar'
...
}
And in the AndroidManifest.xml:
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-feature android:name="android.hardware.location.gps" />
<uses-feature android:name="android.hardware.location.network" />
<meta-data android:name=”com.google.android.gms.version” android:value=”#integer/google_play_services_version”/>
<activity android:name="com.smaato.soma.interstitial.InterstitialActivity" android:resizeableActivity="false" android:screenOrientation="landscape" />
<activity android:name="com.smaato.soma.video.VASTAdActivity" android:resizeableActivity="false" android:screenOrientation="landscape" />
<activity android:name="com.smaato.soma.ExpandedBannerActivity" android:resizeableActivity="false" android:screenOrientation="landscape" />
Besides, Smaato declares that: "Since v8.0.0, the Smaato Android SDK contains an automatic initialization routine. Therefore there is no need for publishers to manually call an additional SDK initialization method".
But running this code, gives me the following alert in the Logcat:
SOMA_VIDEO: Video must be loaded before showing it
So, the video add is not loading at all. What am I missing here?
Can you help me? Thanks.

Solved! Apparently, I hadn't the correct sequence order. With this order, the warning in Logcat vanishes:
smaatoVideoAd = new Video(this.getApplicationContext());
smaatoVideoAd.setVastAdListener(this);
smaatoVideoAd.setAutoCloseDuration(3);
smaatoVideoAd.disableAutoClose(false);
smaatoVideoAd.setVideoSkipInterval(1);
smaatoVideoAd.getAdSettings().setPublisherId(0); // Trial Publisher Id: 0
smaatoVideoAd.getAdSettings().setAdspaceId(3090); // Trial Adspace Id for video: 3090
smaatoVideoAd.asyncLoadNewBanner();
Notice that the code for Smaato video ad in trial mode is 3090, not 0. Also, I have put the Smaato Ad in a new activity, so closing the ad will close the child activity and not my main one.

Related

Unable to close AdMob interstitial ad

Lately, my android app has been showing Admob interstitial ads that cannot be dismissed. It seems the back button action to dismiss an ad was discontinued. Most interstitial ads include a "Close" button on the ad itself, but not all of them do. When an interstitial ad is delivered without a close button, the only way to close the ad is to kill the app.
Here is an example of an ad we received without a close button:
I am using
implementation 'com.google.android.gms:play-services-ads:17.0.0'
in my Gradle build.
So the question is: Is there any way to close an interstitial ad aside from pressing the close button on the ad?
If the interstitial should be cropped so that the close button does not appear, it may be due to the max_aspect setting in your AndroidManifest.
For Interstitial the android.resizeableActivity setting has to be true.
In may application I have set the android.resizeableActivity=true in the application tag
but set my android.max_aspect to 1.8 which is needed for my game.
And only in my main acticity tag i set the android:resizeableActivity="false"
<application
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:resizeableActivity="true"
>
<meta-data android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="#string/admob_App_id" />
<meta-data android:name="com.google.android.gms.games.APP_ID"
android:value="#string/app_id" />
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data android:name="android.max_aspect" android:value="1.8" />
<activity
android:name="com.entwicklerx.macedefense.MainActivity"
android:label="#string/app_name"
android:screenOrientation="landscape"
android:configChanges="keyboardHidden|orientation|screenSize"
android:resizeableActivity="false">
I hope this helps someone who has stumbled into the same problem as I recently
It seem like AdMob did some A/B testing on Back button (back button closed the Ads for some users and did not do anything for other users) but now it seems that AdMob chose the later option (back button do nothing)
I noticed this with some Ads, most probably it is an AdMob bug related to certain Ads creative sizes on some phones.
Also I've noticed that it stopped happening using newer SDK versions.
Interstitital ads can be closed by back button.
Remove all minterstitial.loadad code, and also showad code , which you call fram callback you implemented , like onadclose callback.
mInterstitialAd = new InterstitialAd(this);
mInterstitialAd.setAdUnitId("ca-app-pub-........");
// mInterstitialAd.setAdUnitId("ca-app-pub-......."); /// test ads
MobileAds.initialize(this, new OnInitializationCompleteListener() {
#Override
public void onInitializationComplete(InitializationStatus initializationStatus) {
mInterstitialAd.loadAd(new AdRequest.Builder().build());
mInterstitialAd.setAdListener(new AdListener(){
#Override
public void onAdLoaded() {
super.onAdLoaded();
mInterstitialAd.show();
}
#Override
public void onAdFailedToLoad(int i) {
super.onAdFailedToLoad(i);
}
#Override
public void onAdClicked() {
super.onAdClicked();
}
#Override
public void onAdLeftApplication() {
super.onAdLeftApplication();
}
#Override
public void onAdOpened() {
super.onAdOpened();
}
});
}
});

App not being recognized by Android Auto

So, I followed the official guide here https://developer.android.com/training/auto/start/index.html to create a very basic Android Auto Audio App. For the moment it does nothing, other then declaring what needs to be declared in the manifest and implementing empty onGetRoot() and onLoadChildren().
Problem is, that it is not being recognized by the Android Auto app.
Any idea where to get a working example? What could be wrong?
Manifest:
<service
android:name=".MyService"
android:enabled="true"
android:exported="true">
<intent-filter>
<action android:name=
"android.media.browse.MediaBrowserService"/>
</intent-filter>
</service>
automotive_app_desc.xml:
<automotiveApp>
<uses name="media" />
</automotiveApp>
service:
public class MyService extends MediaBrowserServiceCompat {
public static final String MEDIA_ID_ROOT = "__ROOT__";
#Override
public BrowserRoot onGetRoot(String clientPackageName, int clientUid,
Bundle rootHints) {
//TODO: check if the client is allow access
return new BrowserRoot(MEDIA_ID_ROOT, null);
}
#Override
public void onLoadChildren(final String parentMediaId,
final Result<List<MediaBrowserCompat.MediaItem>> result) {
// Assume for example that the music catalog is already loaded/cached.
List<MediaBrowserCompat.MediaItem> mediaItems = new ArrayList<>();
// Check if this is the root menu:
if (MEDIA_ID_ROOT.equals(parentMediaId)) {
// build the MediaItem objects for the top level,
// and put them in the mediaItems list
} else {
// examine the passed parentMediaId to see which submenu we're at,
// and put the children of that menu in the mediaItems list
}
result.sendResult(mediaItems);
}
You have to go to Android Auto settings, tap many times on the Version entry (the last one) to unlock Developer settings. Then tap on Developer settings menu item and enable Unknown sources. Restart Android Auto and if your app it's ok it will be listed. Worked for me
I didn't see this included in your snippet from the manifest, but double check that this line is also there.
<application>
...
<meta-data android:name="com.google.android.gms.car.application"
android:resource="#xml/automotive_app_desc"/>
...
</application>
I created a sample app matching everything you have (plus the line above), and it appears in Android Auto on the mobile device, as well as the Desktop Head Unit.

Android : How to integrate Flurry Banner Ads from new SDK 5.6.0

Here is my code I wanted to integrate Flurry Banner Ads at the bottom and Top of My App with their NEW SDK.. Please help
My Manifest.xml file
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- Start of Flurry Permission-->
<activity
android:name="com.flurry.android.FlurryFullscreenTakeoverActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize">
</activity>
<!-- End of Flurry Permission -->
My Launcher.java Activity
import com.flurry.android.FlurryAdType;
import com.flurry.android.FlurryAds;
import com.flurry.android.FlurryAdSize;
import com.flurry.android.FlurryAgent;
import com.flurry.android.FlurryAdListener;
public class MainActivity extends Activity {
ProgressDialog progress;
private Context mContext;
FrameLayout mBanner;
public static String apiKey ;
private String adSpace;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle bundle = getIntent().getExtras();
mBanner = (FrameLayout) findViewById(R.id.banner);
mContext = LauncherActivity.this;
apiKey = getResources().getString(R.string.flurry_api_key);
adSpace = getResources().getString(R.string.adSpaceName);
#Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
FlurryAds.fetchAd(mContext, adSpace, mBanner,
FlurryAdSize.BANNER_BOTTOM);
}
My MainScreen.xml Layout
<FrameLayout
android:id="#+id/banner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"/>
My String File
<string name="flurry_api_key">3HVSXVC8XTBT8NCN5SCB</string>
<string name="adSpaceName">MyAdSpace Bottom</string>
The ad's are not displaying on my apps from this codes please let me know where is the problem and tell me how to solve it.
I am using FlurryAds-5.6.0.jar SDK. The error i m getting is Unfortunately Application Has Stop. without showing error in error catalog
Just follow instructions from https://developer.yahoo.com/flurry/docs/publisher/code/android/#banner-ads-integration-code.
And I think it would be better to edit your question and delete your API key as that is a data private to your app.
Also, please consider looking at your LogCat, as it could contain reason of not showing any ad. If your app is new, it could take some time to start appearing.
Enable logging by adding FlurryAgent.setLogLevel(2) before the FlurryAgent.init() call. (http://flurrydev.github.io/FlurryAndroidSDK5xAPI/classcom_1_1flurry_1_1android_1_1FlurryAgent.html#a0133e301ea0f01327b5143fc3974f3ac)
Although FlurryAds.fetchAd() method call is deprecated, it could still be used, if you just wanted to test. But, then, replace it with code from the above link.

Place Picker Automatically close after launch

I want to show place picker so that user can choose location of his/her own choice. But place picker child activity automatically closes after launch. I've check the API key multiple times and other permissions, everything is correct. Here is all the code. Please help!
task_location.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View v) {
try {
PlacePicker.IntentBuilder intentBuilder = new PlacePicker.IntentBuilder();
Intent intent = intentBuilder.build(NewTaskActivity.this);
// Start the Intent by requesting a result, identified by a request code.
startActivityForResult(intent, 123);
} catch (GooglePlayServicesRepairableException e) {
GooglePlayServicesUtil
.getErrorDialog(e.getConnectionStatusCode(), NewTaskActivity.this, 0);
} catch (GooglePlayServicesNotAvailableException e) {
Toast.makeText(NewTaskActivity.this, "Google Play Services is not available.",
Toast.LENGTH_LONG)
.show();
}
}
});
And here is the menifest file.
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<application
android:allowBackup="true"
android:icon="#mipmap/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme"
tools:replace="android:icon">
<meta-data android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<meta-data
android:name="com.google.android.geo.API_KEY"
android:value="AIzaSyAjM9hWUXm8vlABqFbM_fJfQgIFli8HP1E"/>
Please check the logcat of your app for 'PLACES_API_ACCESS_NOT_CONFIGURED' message. If this is the case, enabling the Google Places API for Android in your Google Developer Console for this project should solve your problem.
After A lot of debugging i solved it myself. The problem was package name..Android studio manage package name by itself on project creation. I change the package name in manifest and it was working perfectly fine. but when i get API key from google developers console for place picker, place picker automatically closes without a single character of error.
Then I change the package name by going into -> Module Settings -> Flavors and change the Application ID and it fix the problem.
Make sure that Google Places API is enabled for the API key that you are using in Google API console. For me, I am using the same API key that I use for maps. I just enabled the same key for places api also. That solved my problem.
Use this link to access the Google console: https://console.developers.google.com/flows/enableapi?apiid=placesandroid&reusekey=true
Solved problem by just changing the API key
You can create a new key from here
Instead of enabling the places API, Enable the places SDK for android. Worked for me.
Good Luck :)
Enable both places API as well as Places sdk

AdActivity leak on AdMob (SDK 7.0) for Android

I have memory leaks regarding Interstitial ads of AdMob with AdActivity object. Whenever an ad is shown, AdActivity object count in the memory increments by 1. I inspect all changes via MAT after explicit GC calls. I use the latest versions of everything.
At first, I thought that this is related to how I implemented my UI or project, but creating a fresh and empty project shows the same leak.
This leak has also existed in the previous Admob SDK (Google Play Services) and now it exists in version 7.0 too.
I see that people try to solve these kinds of issues by creating a SingleInstance empty activity just to show and set as the context of the interstitial ads. I tried them all and they did not work for my case. Some did help but I even couldn't use it because of the flow of my app. launchMode in Android has limitations and it does not help me on my case.
I already notified the AdMob team but even they fix it, it doesn't seem to happen in a short time as they have just released the version 7.0 SDK.
I do not understand how others do not report leaks like this. It cannot be a special case just for me as it happens on even samples or default templates. If anyone somehow solved this issue (including ugly reflection hacks) please share your experience. I have been working on this for months! Really!
AndroidManifest:
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="22" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<application
android:name="MyApplication"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name" >
<meta-data
android:name="com.google.android.gms.version"
android:value="#integer/google_play_services_version" />
<activity
android:name=".MainActivity"
android:label="#string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
android:theme="#android:style/Theme.Translucent" />
</application>
MainActivity:
package com.example.leaktest1;
import com.google.android.gms.ads.AdListener;
import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.InterstitialAd;
import android.app.Activity;
import android.os.Bundle;
public class MainActivity extends Activity {
private InterstitialAd interstitial=null;
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
interstitial= new InterstitialAd(getApplicationContext());
interstitial.setAdUnitId("YOUR-ADD-ID");
AdRequest adRequest2 = new AdRequest.Builder()
// .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.build();
interstitial.setAdListener(new AdListener() {
#Override
public void onAdLoaded() {
super.onAdLoaded();
if(interstitial.isLoaded()){
interstitial.show();
}
}
});
interstitial.loadAd(adRequest2);
}
#Override
protected void onDestroy() {
if(interstitial!=null){
interstitial.setAdListener(null);
interstitial=null;
}
super.onDestroy();
}
}
Layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context="com.example.leaktest1.MainActivity" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/hello_world" />
</RelativeLayout>
Start the app. When the ad is shown, close it with backpress and hit back button again to exit app.
App will still be in memory, but the activity is gone. Now touch the app icon to start the activity again, it will show the ad again, exit like you did before.
Cause GC multiple times and get heap dump. You will see that there are 2 AdActivity objects (and also many other related objects). It will continue to grow according to the number of shown ads.
The following did not work too (it still leaks):
/*
interstitial.setAdListener(new AdListener() {
#Override
public void onAdLoaded() {
super.onAdLoaded();
}
});*/
interstitial.loadAd(adRequest2);
Runnable r=new Runnable() {
#Override
public void run() {
if(interstitial.isLoaded()){
interstitial.show();
}
}};
new Handler().postDelayed(r,10000);
And putting code inside a button did not work too (it still leaks):
Button b = new Button(this);
b.setText("Touch me");
b.setOnClickListener(new OnClickListener() {
#Override
public void onClick(View v) {
if(interstitial.isLoaded()){
interstitial.show();
}
}
});
ViewGroup v = (ViewGroup) this.findViewById(android.R.id.content);
v.addView(b);
Leak platform and exceptions:
This leak happens on various devices from Samsung and Asus with various un-modded (original firmware) Androis systems from 2.3 to 4.4. It also happens on any setup of android simulator.
(This leak does not show up on rooted Cyanogenmod (Galaxy S3) Android 4.4.4)
UPDATE
The leak does not vanish if I use Activity context instead of Application context. It also causes Activity leak too.

Categories

Resources