I would like to an admob banner in my app, showing ads in specific categories (every device would have a specific categories).
For example, app installed on one device would show only music, other would show only travel, etc.
I looked in Google developers guide and PublisherAdRequest API and notice the following example:
// Example: Pass custom targeting "Age=25", "Color=Blue,Green,Red"
private PublisherAdRequest createRequest() {
Bundle bundle = new Bundle();
bundle.putString("Age", "25");
bundle.putString("Color", "Blue,Green,Red");
return new PublisherAdRequest.Builder()
.addNetworkExtras(new AdMobExtras(bundle))
.build();
}
My question is - What keywords are available for me?
If I would like to get only Music and travel related ads, what keywords should I use?
Is there another way to do it?
Related
When I try to load an interstitial with inmobi.com and most of the times I get the error "ad request successful but no ad served". Why is this happening? Any solution for this? It works well with testing ads when set to "Test mode" in the website. Will this be because inmobi has not enough providers to display ads at that moment?
I asked Inmobi support page but they don't answer. I am starting to regret moving from admob to inmobi.
This is the code I use:
JSONObject consentObject = new JSONObject();
try {
consentObject.put(InMobiSdk.IM_GDPR_CONSENT_AVAILABLE, true); // Provide correct consent value to sdk which is obtained by User
consentObject.put("gdpr", "1"); // Provide 0 if GDPR is not applicable and 1 if applicable
//consentObject.put(InMobiSdk.IM_GDPR_CONSENT_IAB, “<<consent in IAB format>>”); // Provide user consent in IAB format
} catch (JSONException e) {
}
InMobiSdk.init(this, "My InMobi Account ID here", consentObject);
long MyPlacementID = 1234566789L; //My Placement ID here as long
mInterstitialAd = new InMobiInterstitial(this, MyPlacementID, new InterstitialAdEventListener() {
#Override
public void onAdLoadSucceeded(InMobiInterstitial inMobiInterstitial) {
super.onAdLoadSucceeded(inMobiInterstitial);
if (inMobiInterstitial.isReady()) {
mInterstitialAd.show();
}
#Override
public void onAdLoadFailed(InMobiInterstitial inMobiInterstitial, InMobiAdRequestStatus inMobiAdRequestStatus) {
sError = inMobiAdRequestStatus.getMessage();
Here I get error: "ad request successful but no ad served"
}
I emailed the support team and they answered that is shown if they don't have any ad to be displayed (maybe for my location or for my time). So, it is just that they run out of ads to be displayed. If I try it many many times then I may get one ad. So it is a server problem. Not enough clients to pay for ads. It is a pity.
I was having the same issue.I tried different ways to get the test ads.But everything was in vein.Then i went through their documentation and found that we need to set up a layout for ad placement.There is an option to customize that.Click on save and then add your device id in the testing devices section, you will see test ads coming up.I found this one from an article where it said "If you set banner sizes different from those provided by default, the SDK will refuse to load data and will issue a corresponding message to the log:
[InMobi]: Failed to fetch ad for placement id: 201901231449, reason phrase available in onAdLoadFailed callback.
And the message “Ad request successful but no ad served” with the code “NO_FILL” appears in the listener's method. Hence our expert advice: always redefine the listener's methods which are responsible for errors. Acting such a way, you'll avoid many difficulties later."
https://agilie.com/en/blog/how-to-integrate-inmobi-sdk-to-start-monetizing-your-android-app
Contradicting answer to #Ton's answer.
All the ad servers work in the following manner. Advertisers pay for ads with specific targetted audiences. So whenever you ask an ad network to provide an ad it actually checks if they have an ad for which targeting is matched with the current user (for ex. area, gender, age as and when available). If they don't have any ad which can be shown to the current user then they will fire NO_FILL.
Also, specific to InMobi, they don't provide many ads on emulators so try on a physical device to get ads.
I'm using Facebook's NativeAdManager for Android as intended:
nativeAdsManager = new NativeAdsManager(context, "my_placement_id", 3);
which should load me 3 different ads, and them allow me to get them in my adapter using:
NativeAd adItem = nativeAdsManager.nextNativeAd();
but for some reason I always get the same ad. According to their reference:
The NativeAdsManager provides a mechanism to fetch a set of NativeAds and then use them within your application. The recommended usage is to call nextNativeAd() at the moment when you are about to render an ad. The NativeAdsManager can hold at most 10 unique ads at once but supports giving out as many ads as needed by cloning over the set of NativeAds it got back from the server which can be useful for feed scenarios.
Am I missing something here?
I've an android app that parses notifications and displays all (most of) the contents in a custom interface.
I get the required data in all cases, but except for Google Pay (Formerly Tez in India) and Google Photos. In case of these apps, all the bundle values give me null, even checked while debugging. This is weird. Checked in the Notification Log hidden in Android Settings menu and it shows the values are present but at API level, I only get the bitmap and some "caption text". Rest all are NULL.
My code looks like below (null checks omitted)
Bundle extras = sbn.getNotification().extras;
content_title = extras.get(Notification.EXTRA_TITLE).toString();
a = extras.get(Notification.EXTRA_BIG_TEXT).toString();
b= extras.get(Notification.EXTRA_TEXT).toString();
c= extras.get(Notification.EXTRA_SUMMARY_TEXT).toString();
icon = (Bitmap) extras.get(Notification.EXTRA_LARGE_ICON);
lines = (CharSequence[]) extras.get(Notification.EXTRA_TEXT_LINES);
I suspect there is some kind of sensitive data protection stuff going on here. But why then only these two apps? Tez maybe a payments app, but why Google Photos? And what is the documentation and reference to such behavior?
I am trying to show an App request dialog that shows a list of friends that are not users of my app to send invites. This is how i am going about it.
Bundle parameters = new Bundle();
parameters.putString("message", "Send Request");
String filters = "app_non_users";
parameters.putString("filters", filters);
WebDialog.Builder builder = new Builder(context,Session.getActiveSession(), "apprequests", parameters);
// add listener
WebDialog webDialog = builder.build();
webDialog.show();
It shows a dialog like this with "Suggested Friends".
These are not the friends i want. i want only the non app users and these are all my friends under the suggested friends heading. If i supply facebook ids in a parameter of "suggestions", it rightly shows those facebook ids under the suggestions but this "filters" parameter is not working. I have also tried adding it as a string array. Am i doing something wrong?
Thanks
Let me answer it just in case someone else comes across this too. This code will work if you are using v2 of the API. i had not completely moved to v2, i was running in the compatibility mode (Settings.setPlatformCompatibilityEnabled(true);) and because of that the call was being made to the v1 API by default. Changed this and its working like a charm.
Let me answer it just in case someone else comes
across this too. This code will work if you are using
v2 of the API. i had not completely moved to v2, i
was running in the compatibility mode
( Settings.setPlatformCompatibilityEnabl
(true); ) and because of that the call was being
made to the v1 API by default. Changed this and its
working like a charm.
I am using admobs in my android app and would like to test it with selected users on forums , family and friends.
I would like to display the test ads on their devices to avoid issues with conditions.
The doc says:
adRequest.addTestDevice("TEST_DEVICE_ID");// Test Android Device
But as I plan to share to non-tech people, I am pretty sure they won't be able to get their devices ID.
Is there a way to force displaying test ads on any devices?
Thank a lot.
You can use below line
adRequest.setTesting(true);
See I have used like this for testing purpose
AdRequest adRequest = new AdRequest();
adRequest.setTesting(true);
adView.loadAd(adRequest);
I don't know if there is a way to display test ads on select devices, but you could insert a view that has the same dimensions as the ad (50 by 350 I think?) and make it clear that an ad should go there. If you really wanted to you could even make it an image view, take a screen shot of Google's test ad, and create an onClickListener that sends you to Google.com.
This one was the correct answer
https://stackoverflow.com/a/8665279/327402
Not official but at least, that works!
String aid = Settings.Secure.getString(getContext().getContentResolver(), "android_id");
Object obj = null;
try {
((MessageDigest) (obj = MessageDigest.getInstance("MD5"))).update(
aid.getBytes(), 0, aid.length());
obj = String.format("%032X", new Object[] { new BigInteger(1,
((MessageDigest) obj).digest()) });
} catch (NoSuchAlgorithmException localNoSuchAlgorithmException) {
obj = aid.substring(0, 32);
}
adRequest.addTestDevice(obj.toString());