I am implementing an android application which checks whether an installed application can show ads or not.
What is the safest way to achieve this?
Thanks in advance.
Get All Applicaitons that are installed.
final PackageManager pm = getPackageManager();
List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);
Check The Appstore using the app id to check if it has ads
Home Page For Apps: https://play.google.com/store/apps?hl=en
App Page: https://play.google.com/store/apps/details?id=com.bandainamcogames.dbzdokkanww&hl=en
just replace the id's value of com.bandainamcogames.dbzdokkanww with the app package from the packages list
then check the page for "Contains Ads"
Refs:
Get All Apps
An ad is an element from the Web. Every element loaded from the web is essentially a HTTP request. You could implement in your application some mechanism to check the HTTP requests generated in real time by other applications and block them.
Related
SITUATION
I have a set of functionalities in my app which changes based on the store it is installed from. E.g. I want to have a more restricted set of advertisements displayed for family audiences and children to be eligible for the Google Play for Education category. In other stores i still want to restrict but don't want to be as stringent as I will be in filtering out the ads.
General observation at my end is that if I opt-in for "Google Play for Education" category it takes a few more hours to get published because of the following (as stated on the developer console):
Checking this box submits this app for inclusion in the "educator
recommended" section of Google Play for Education. The final decision
on which apps to recommend is made by a 3rd party network of teachers.
If your app is selected, we will notify you by e-mail. If not, your
app will still be searchable in Google Play for Education.
Now before the app gets published in this category the network of teachers, I assume, download and test/verify if the guidelines are met and there are no violations.
PROBLEM
To differentiate between the store installed from I'm obviously using this:
PackageManager packageManager = context.getPackageManager();
String installer = packageManager.getInstallerPackageName(packageName);
if (installer == null) installer = ""; //to avoid NPE
if (installer.equals("com.android.vending")) {
//It is installed from Google Play store
//PROBLEM: THIS DOES NOT SEEM TO BE THE PACKAGE NAME RETURNED
//WHEN GOOGLE PLAY REVIEWERS/TESTERS ARE USING THE APP
}
else ...
....
....
//similarly handling other stores here
....
....
....
//After that also checking by installed app stores
....
....
What is happening: After being published things app properly identifies that it is downloaded from play store i.e. it gets com.android.vending as the installerPackageName. But, when it is being reviewed or tested by the network of teachers it appears to be getting a different installerPackageName. This is causing the app to think it has been downloaded from an app store other than Google Play Store. And because of this my app is rejected from the Education category. I need to know this installer package name to handle the scenario correctly.
How do i know this: I have a dedicated ad unit id to use when the detected app store is Google Play and all requests post successful publication (i.e. from the regular play store users) come to this google dedicated ad unit id. But, in the short span of time after submitting the app/update and before the app or and update is published, a few requests come to the non-google ad unit ids, causing the app to fail adherence to the guidelines to be eligible for "Google Play for Education" category. Because, the level of ad filtering in the non-google ad unit ids is slightly less. Hence the teachers evaluating/testing the app see some ads that they think are not as per guidelines and reject it.
Also, here is an article to support the fact that the app gets reviewed manually as well as by automated script before it is actually published to the store.
Current fix or limitation: I've disabled all other ad networks and have to use only admob. The setting of filters even at the strictest level in other ad networks doesn't seem to filter all ads that Google reviewers think are not suitable for children and family audiences. When using only admob the process is smooth and I always qualify.
What I'm looking for to overcome this problem: If i get to know the installerPackageName that is returned when the app is installed from where ever the reviewing network of teachers install the app from, I can handle that case exactly as i handle when i get com.android.vending and everything will be just fine.
I could not find any documentation or reference to obtain this information.
Also, if there is any other way i can identify it the app is in pending publication stage, I force all requests to go to the google ad unit id.
ASSUMPTION: There is a separate installer app for the reviewers and testers (automated/manual what ever it may be in the background) whose installerPackageName is NOT com.android.vending. If there is some Google guy around and can help confirm this (if allowed by Google), do comment. :-)
Other possibilities which i do not want to go with
Disable all other networks manually while the app is in pending publication phase and re-enable them once published. But, I don't want to do this because this would be like bluffing google and I don't want to go that way. I want my app logic to take care of it so that the same thing that is reviewed is let out in market.
I permanently stick with only admob. But this would be foolish as there are no such restrictions in other stores that I'm publishing my apps to and I will terribly lose on fill rate.
I there anyone who has had this issue before OR knows the installerPackageName for the review's download place OR knows how to determine if the app is currently in 'pending publication` state on playstore?
I can also possibly filter all by packagenames starting with com.android or com.google, but I want to keep that as last option. Also, would like to know if the installerPackage name is not set at all in case of those users. In that case I'll need to look at a completely different situation to handle the situation.
I find one thing that can help you in this case. It's analytics. Just create your custom event eg. INSTALLER_STRING in some of analytics systems and log that event when appropriate. Here is the example of event logging in Fabric Answers.
public static final String EVENT_OPEN_TOP_TRENDS = "EVENT_OPEN_TOP_TRENDS";
public static final String TOP_TRENDS_TYPE = "TOP_TRENDS_TYPE";
public static final String TYPE_TOP_TRENDS_IMAGES = "TYPE_TOP_TRENDS_IMAGES";
public static void logEvent(String eventId, String attributeName, String name) {
Answers.getInstance().logCustom(new CustomEvent(eventId).putCustomAttribute(attributeName, name));
}
logEvent(EVENT_OPEN_TOP_TRENDS, TOP_TRENDS_TYPE, TYPE_TOP_TRENDS_IMAGES);
Later on, you can see what are the sources your app was installer from on fabric website.
Check which results you will show using this log for all app you use do detect installer package name:
final PackageManager pm = getPackageManager();
//get a list of installed apps.
List<ApplicationInfo> packages = pm.getInstalledApplications(PackageManager.GET_META_DATA);
for (ApplicationInfo packageInfo : packages) {
String is = pm.getInstallerPackageName(packageInfo.packageName);//getPackageName());
Log.d(TAG, (packageInfo.packageName==null?"":packageInfo.packageName) + " : " + (is==null?"":is));
}
You will see the full list of installed apps & package sources, or log this data in your way your want.
EDIT
#Virus, i just want to give you a simple idea. if you want to know package installer name, you can just grab this data when you app is launched and send it to your own server using simple http GET request in order to detect the installer name. Republish you apo with this simple frabber. I think this the one solution.
I want to make an app which will pay users money on downloading another apps from within my app, so how can i track that user had downloaded that app or not, and i want to make sure that after user registered in the downloaded app then only he/she is going to get money, so how can i do this.
Some examples of these types of apps are : Ladooo app, TaskBucks App, Pokkt App,
I found following links which helped me somehow but it is not clear :
http://android-developers.blogspot.in/2010/12/analytics-for-android-apps.html
https://developers.google.com/analytics/devguides/collection/android/v4/
you can retrieve the list of installed applications in the following manner
// retrieve the list of installed applications
List<ApplicationInfo> apps = mPm.getInstalledApplications(0);
can get the package name of the app through
String pkg = apps.get(i).packageName;
I know this is not the full answer but i hope this helps
Not Sure About your requirement or not have idea about playstore api but can give simple logic for this, hope it will help.
When any user share or refer the application for download to other user, create one unique id from the serverside(combination with user who refer) in simple word redirect url to playstore with uniqueid and share that link with intent.
When user register you can check or if redirect url for playstore is via your server than you can send money or points when redirect link callback on server.
check this
or you can refer some codes on github:
here or here
I am developing an Android application where I want people to buy a licence, and based on that licence I will need to push plugins to my application.
e.g. if the licence maps to 3 plugins (or premium features), I want to push only those 3 to the application at run time. Since it's not possible to change the APK like this AFAIK, and I don't want to include all the features in a single APK.
How can I maintain multiple versions of the app, like a premium app and free app without maintaining multiple apks?
Best Regards
Plugins are nothing but APKs without a launcher activity AFAIK. Just take the example of the Facebook. How does the application know whether you have their Pages Manager or Messenger installed ? I can only think of one way of achieving this so-called Plugin Based Architecture i.e. Create multiple APKs, one for each plugin, acting as a stand-alone application. And check if the package exists at Runtime with the Main APK.
public boolean isPackageExisted(String targetPackage){
List<ApplicationInfo> packages;
PackageManager pm;
pm = getPackageManager();
packages = pm.getInstalledApplications(0);
for (ApplicationInfo packageInfo : packages) {
if(packageInfo.packageName.equals(targetPackage)) return true;
}
return false;
}
If not downloaded and install the package if it meets your criteria.
How do I make sure that only my "master" apk is able to call the functions in the plugin apk?
You can do that by adding this to your Manifest file
android:protectionLevel="signature".
You can read about it more here.
Hope this helps.. :)
I know in Android, I can invoke getInstalledPackages(0) of PackageManager API to get all the installed apps on device.
I am wondering is there a way or workaround to get the publisher's name of installed app by using Android SDK (i.e. no 3rd party library)??
The package that contains related classes, especially ApplicationInfo, there is no public interface for this (http://developer.android.com/reference/android/content/pm/package-summary.html). So i belive there's no way to do that.
I think there is no direct way to do that. Because that information is not available anywhere in the manifest or source code.
As a workaround, you can get the process name/package name, and find publishers name from google play store:
Pseudo code:
List<ApplicationInfo> appInfos = context.getPackageManager().getInstalledApplications(0);
for (ApplicationInfo appInfo : appInfos) {
String processName = appInfo.processName; // Example: com.google.android.youtube
String url = "https://play.google.com/store/apps/details?id=" + processName;
// Fetch publisher name from web here
...
}
I think, there is no android API to get the publisher's name of the application. You can get the publisher's and more information from the play store using this 3rd party API.
https://api.appmonsta.com/v1/stores/android/details/your-package-name.json?country=us
Replace the 'your-package-name' from API to the application package name.
First, you have to register with api.appmonsta.com to run this API.
I want to share link to my app(link on play.google) using facebook api. But I have to have it before posting app on market to put it in my code. Are there any other solutions except updating my app right after posting?
use this
https://play.google.com/store/apps/details?id=<your package name>
and you can get package name by this way.
String packageName = getApplicationContext().getPackageName();
currently it will not show any app but after publishing it automatically redirect in your app page.