TLDR: I get real ads even if I use a sample unit id provided by Google for testing.
I implemented native ads in my application.
I am using the Native Advanced sample ad unit as described here:
https://developers.google.com/admob/android/test-ads
However, the ads I get look very real, even though they have a "Test Ad" text in the title, and they also redirect me to real company websites. This has not happened with banner ads, I only got Google sample ads previously (e.g. Nice job, this is a test ad).
Some of the ads are coming from well-known restaurants in my country, and clicking on them navigates me to their website. I don't use my own unit id anywhere.
This is the code I use to initialize ads.
public static final String UNIFIED_AD_UNIT_ID = "ca-app-pub-3940256099942544/2247696110";
MobileAds.initialize(context, initializationStatus -> {
});
AdLoader adLoader = new AdLoader.Builder(context, UNIFIED_AD_UNIT_ID)
.forUnifiedNativeAd(unifiedNativeAd -> {
populateNativeAdView(unifiedNativeAd, nativeAdView);
}).build();
adLoader.loadAd(new AdRequest.Builder().build());
}
Is this a bug, or am I doing something wrong? (Or are these really test ads?) I really don't want to get banned from AdMob.
If you start your App running Android Studio, you can get the test device id for your device from the logcat at the bottom of Android Studio. Add this to your builder. By the way, the ads you are getting are looking like they should.
Related
I'm still testing my app ads and I use this code to generate test ads.
But I was wondering if there is any difference between using AdRequest.DEVICE_ID_EMULATOR and using the id generated in logcat?
Code I'm using
adLoader.loadAd(new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build());
I would so encourage to just use test ads provided by Google.
AdView adView = new AdView(this);
adView.setAdSize(AdSize.BANNER);
adView.setAdUnitId(BuildConfig.DEBUG ? "ca-app-pub-3940256099942544/6300978111" : "yourRealAdUnitID");
So much simpler than messing around with multiple test devices.
I am developing an andorid app which post some photo on Facebook, at the same time I want to calculate the number of likes of that photo from my android app.
For information -
I am using Facebook SDK and I have successfully logged in Facebook account and posted the image.
The method which post image is below
private void PublishImage()
{
Bitmap image = BitmapFactory.decodeResource(getResources(),R.mipmap.ic_launcher);
//Here we set all the required parameters to share the image and build that
SharePhoto photo = new SharePhoto.Builder()
.setBitmap(image)
.setCaption("Testing Sharing Feature through java")
.build();
//Now we share the PhotoContent by adding the properties in instance of SharePhotoContent
share = new SharePhotoContent.Builder()
.addPhoto(photo)
.build();
//Now we use share API to share the image
ShareApi.share(share,null);
}
How to calculate the number of likes of posted photo with java instead of using Graph API Explorer manually ?
I don't think you can do that without the graph API. Once you call ShareApi.share (), there is actually a graph API request which uploads the photo, and you will get likes from various platforms, your app has no way of knowing how many likes have been posted
After updating to "new abMob", it appears to have this problem...
use this code, but nothing displays:
adView = new AdView(this, AdSize.BANNER, "pub-xxxxxxxxxxxxxxxx");
and got warning:
Invalid unknown request error: Cannot determine request type. Is your
ad unit id correct?
What's wrong?
Using android emulator, admob 6.4.1
In my case, the ad unit id was incorrect in AdMob app management section! There was a ~ instead of / in the id. I fixed it by viewing the GoogleService info plist and found the correct unit id.
Change:
ca-app-pub-XXXXXXXXXX~XXXXXXXXXX
to:
ca-app-pub-XXXXXXXXXX/XXXXXXXXXX
The adUnit Ids in the new Admob console are of the form:
ca-app-pub-XXXXXXXXXXXXXXXX/YYYYYYYYYY
This is what your problem is.
Go check your Admob console and update your app to reflect that.
First you have to go to www.admob.com. There sign in with your account. Then klick at "Monetize" next to "Home". There you have to add your app and set the settings for your advertisement. After that, the website is asking you to send you an e-mail with your ad unit id, you have to put in your strings.xml file instead of the exsample id. Hope this helps.
#if UNITY_ANDROID
string adUnitId = " ca-app-pub-8572140050384888/1853336688 "; //no spaces are allowed before and after admob-id..
Change to :
#if UNITY_ANDROID
string adUnitId = "ca-app-pub-8572140050384888/1853336688";
android java admobunity
You don't need to have an app already on the market to get a Publisher ID for a new app. In the Android Package URL field that's on the "Add Site/App" form, just enter "market://details?id=your.package.name". You'll of course want to replace the 'your.package.name' with your app's actual package name.
The viewWidth warnings are fine and you will likely still see them after inserting your Publisher ID.
Refer below links..
How to get Google's example code working for AdMob 4.1.0 using an Android device
AdMob 4.3.1 adds not showing up (No AdMob ID yet (just for test), can't get ViewWidth)
Try this format
GADBannerView * bannerView_;
bannerView_ = [[GADBannerView alloc] initWithAdSize:kGADAdSizeBanner];
bannerView_.adUnitID=#"ca-app-pub-5250422073333775/6825580043"; //Id for Top Banners
bannerView_.rootViewController = self;
[self.view addSubview:bannerView_];
[bannerView_ loadRequest:[GADRequest request]];
I know there are several Qs here that ask if its possible to add badges to an android app and they all end up with a NO answer...
But somehow the latest Facebook beta version for Android seems to do something which at least look like a badge even if it is not technically exactly that.
In that post one of the commenters says that it is somehow related to TouchWiz.
And also here they mention it as a feature of the "S3 TouchWiz Jelly Bean Addon".
I still would appreciate information on how does this can be done and if there is some API for this that I can use in my own app (when running in an appropriate environment - i.e. the same device where FB demonstrates this behavior) ?
Hi you can use this lib simply.
Support : Sony,Samsung,LG,HTC,Xiaomi,ASUS,ADW,APEX,NOVA,Huawei,ZUK,OPPO
ShortcutBadger
Add :
int badgeCount = 1;
ShortcutBadger.applyCount(context, badgeCount);
Remove :
ShortcutBadger.applyCount(context, 0);
I have figured out how this is done for Sony devices.
I've blogged about it here. I've also posted a seperate SO question about this here.
Sony devices use a class named BadgeReciever.
Declare the com.sonyericsson.home.permission.BROADCAST_BADGE permission in your manifest file:
Broadcast an Intent to the BadgeReceiver:
Intent intent = new Intent();
intent.setAction("com.sonyericsson.home.action.UPDATE_BADGE");
intent.putExtra("com.sonyericsson.home.intent.extra.badge.ACTIVITY_NAME", "com.yourdomain.yourapp.MainActivity");
intent.putExtra("com.sonyericsson.home.intent.extra.badge.SHOW_MESSAGE", true);
intent.putExtra("com.sonyericsson.home.intent.extra.badge.MESSAGE", "99");
intent.putExtra("com.sonyericsson.home.intent.extra.badge.PACKAGE_NAME", "com.yourdomain.yourapp");
sendBroadcast(intent);
Done. Once this Intent is broadcast the launcher should show a badge on your application icon.
To remove the badge again, simply send a new broadcast, this time with SHOW_MESSAGE set to false:
intent.putExtra("com.sonyericsson.home.intent.extra.badge.SHOW_MESSAGE", false);
I've excluded details on how I found this to keep the answer short, but it's all available in the blog. Might be an interesting read for someone.
There is not a standard way to achieve this; Many makers such as Sony or Samsung have implemented it in their own Android customization.
For example in Samsung, you have to broadcast an intent with BADGE_COUNT_UPDATE action, let MainActivity be your main activity class and count be the number you want to display in your app icon, note that 0 will hide the badge:
Intent intent = new Intent("android.intent.action.BADGE_COUNT_UPDATE");
intent.putExtra("badge_count", count);
intent.putExtra("badge_count_package_name", context.getPackageName());
intent.putExtra("badge_count_class_name", MainActivity.class.getName());
context.sendBroadcast(intent);
Sony devices uses "com.sonyericsson.home.action.UPDATE_BADGE" action with their custom extras as #Marcus Answered, so you have to add "com.sonyericsson.home.permission.BROADCAST_BADGE" permission to your app manifest and:
Intent intent = new Intent("com.sonyericsson.home.action.UPDATE_BADGE");
intent.putExtra("com.sonyericsson.home.intent.extra.badge.ACTIVITY_NAME", MainActivity.class.getName());
intent.putExtra("com.sonyericsson.home.intent.extra.badge.SHOW_MESSAGE", true);
intent.putExtra("com.sonyericsson.home.intent.extra.badge.MESSAGE", String.valueOf(count));
intent.putExtra("com.sonyericsson.home.intent.extra.badge.PACKAGE_NAME", context.getPackageName());
context.sendBroadcast(intent);
Note: it's desirable to query your app's data (context.getPackageName(), MainActivity.class.getName()) rather than hardcode it just in case you do some refactoring in the future.
But somehow the latest Facebook beta version for android does just that...
Not according to the forum thread that contains the screenshot that you linked to. Quoting vakama94:
Well, that's actually TouchWiz and not just the app. I have a Galaxy S II running JellyBean 4.1.2 and it makes the same thing but with some other applications
Whether Samsung has a public API to allow apps to publish numbers to be used as badges, I cannot say. This could be something that they did privately with a few firms.
You are welcome to provide evidence of seeing these badges on a stock Android home screen, such as one of the Nexus series devices.
I answer to this assuming that some flutter dev can search this...
In Flutter, you can achieve this by using
Flutter app badger library.
It is as simple as
FlutterAppBadger.updateBadgeCount(1); // show
FlutterAppBadger.removeBadge(); // hide
I need some advice for this matter...
I used the facebook android sdk to create an integration with facebook from my application...I followed this tutorial:
http://www.integratingstuff.com/2010/10/14/integrating-facebook-into-an-android-application/
I would need to implement authentication in one activity and the function postToWall in another.... after authentication i want to send post simply by pressing a button but in other activity, different from that where i do authentication.
is it possible? or with the SDK I'm forced to do everything together in the same activity?
thanks in advance
Yes it is possible. You will get a access token which you can send to the next activity. Use getAccessToken() and setAccessToken().
Here is an example that even saves the needed data: Contact-Picture-Sync
you need to install an extension, similar to the core Android SDK, but no, here is what you need to do:
1.) go to github.com/facebook/facebook-android-sdk
2.) download the facebook directory ONLY! The other directories are only examples.
3.) Put the files from the src (you can copy the drawables too, if you want to) in the package, you are currently working with
4.) You are good to go, you can use the facebook "SDK"
see also this example https://github.com/facebook/facebook-android-sdk/tree/master/examples/Hackbook download it , it is working example provided by facebook
just to provide an alternative answer, there's other ways of implementing sharing on Android.
It allows for more sharing options (like Twitter, QR-Barcodes, blogging and whatnot) without having to deal with the facebook android sdk.
What you would use is a "share" intent, like so:
String title = "My thing"; // used if you share through email or channels that require a headline for the content, always include this or some apps might not parse the content right
String wallPost = "Hey - check out this stuff: http://link.com "; // the content of your wallpost
String shareVia = "Share this stuff via"; // the headline for your chooser, where the phones avaliable sharing mechanisms are offered.
Intent shareIntent = new Intent(android.content.Intent.ACTION_SEND);
shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
shareIntent.setType("text/plain");
shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, title);
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, wallPost);
startActivity(Intent.createChooser(shareIntent, shareVia));
This is by far the preferred solution on Android if you're looking for simple sharing, as it makes your app future-compatible with new services. And more lean and flexible for the user too, as there's little to no friction from hitting the share button to posting content.
It can also be seen in this blog post: http://android-developers.blogspot.com/2012/02/share-with-intents.html
I hope you can use this for your project.