Deploy service to Google Play - android

I would like to create a service (let's call it Service A) that runs on Android and is used by 3rd party applications (let's call one of these applications Application B). Such a solution would be similar to Google Play Services for AR.
I'm trying to understand how to create the dependency between Application B, and Service A on the store, such that when installing Application B, Service A is also installed.
To return to the Google Play Services for AR example, as a 3rd party app developer, I just have to specify a dependency to the ARCore library, and when I install the app on a device, the service is also installed.
The reason I want to do this is to be able to update Service A independently of updates to Application B, as the release cycle of Application B is not under my control.

In order to create the dependency between Application B, and Service A You can definitely utilize the uses-library Manifest tag to prevent people from downloading it from the store without your custom dependency being on their device, but this will only prevent them from obtaining it from the store; they could still download it a myriad of other ways.
Your best bet would be to have your application launch to a specific launch activity that checks if the package exists on their device:
public static boolean doesUseHaveMyDependency(Context context){
try{
context.getPackageManager().getApplicationInfo("com.yourlib.package", 0 );
return true;
} catch( PackageManager.NameNotFoundException e ){
return false;
}
}
With that, you can determine if your custom library is installed. If not, simply redirect them to the download link to obtain it, then when they reopen the app you check again. Once you have confirmed that they have it, you can progress to the main application.

Related

Why does ActivityManager.runningAppProcesses returns current running app, only?

On my AndroidTV Emulator I have:
val am = this.getSystemService(ACTIVITY_SERVICE) as ActivityManager
am.runningAppProcesses?.forEach {
Logger.debug("XXX", "Running ${it.uid} , ${it.processName}, ${it.pid}")
}
I also start other 3rd party apps, but I dont kill them.
The Google Docs say:
Returns a list of application processes that are running on the
device.
for ActivityManager.runningAppProcesses.
When executing this code from Android Studio, runningAppProcesses list has always size 1 and its the current app triggered from Android Studio?
I was expecting, that these 3rd party apps, I launched earlier are listed there as well?
What is meant by "application processes that are running on the device"? Are backgroundprocesses not included there?
How can I do so?

Conflict in keeping two Apps compatible due to new Android and GooglePlay restrictions

I have published 2 Apps, let's call them A and B, where B provides a remote service which is started by A and, if installed, enhances A's functionality.
Besides the remote service, App B contains just one activity, which is typically used only once to do the initial setup.
Now it seems impossible to update B due to the following conflicting conditions:
a) For new uploads to GooglePlay the target SDK must be at least 29.
b) A service published under this target SDK can not be started from the background, which my App A is doing.
I can of course also upgrade my App A, such that it calls the service from the foreground. But all users, which are upgrading App B at first, will see App A immediately crashing, when it tries to connect to the new version of my Service B.
So the only solution I can currently think of, is as follows:
Instead of upgrading B, I will have to publish a new App C.
The upgraded version of A will then check, if only B is available. If so, it will warn the user, that B was deprecated and that C should be installed.
The App C could also check in its initial setup screen, if A was already updated, and inform the user, that C will not be used, as long as A is not upgraded.
Although this sounds feasible, it is not what users would expect.
So I would be interested, if someone had a similar situation with a better strategy to solve this conflict.

How does buying an app to enable paid features of another app work?

There are apps (such as https://play.google.com/store/apps/details?id=com.teslacoilsw.launcher) that are free, but whose paid features can be enabled by buying another app (in this case, this one https://play.google.com/store/apps/details?id=com.teslacoilsw.launcher.prime)
How does this work?
My guess is that the free apps launches an explicit Intent and can detect if the app is present via a try/catch structure. The downside of this is that this could be easily circunvented by someone who creates an app with the same package name and specifies all possible Intent filters.
Is this how it works, or is it some other way?
There are various ways to do that. One way is to query a content provider which will be protected with a special permission.
I have released quite long ago on Github a library which helps doing this: Android Unlocker Library.
That's a good option if you are dealing with devices outside the Google ecosystem, however, from a developer experience, in-app purchases offer a much better user experience (and thus drive more sales) according to me.
The easiest way is to use startActivityForResult(...) from app A against an Activity of app B, that must be configured with an IntentFilter in order to be used from an outer app. Inside the B called activity you can also check who's calling with getCallingActivity(). You can find an example here.
Before starting the Activity, you can test that B is installed (using the PackageManager) or you can just start the activity and catch the Exception.
In the called Activity, you can check the signature of the calling package using the PackageManager.checkSignature(String,String) method. Pass the package name of A and B and if the signature matches, execute the logic.

Updating Google Play Services

ALL,
I'm trying to develop an Android application. The application will use the GeoLocation which is based on the Google Play Services.
I also have a phone for testing (Samsung with Android 4.2.2). When checking things with Eclipse I see that the device has this service but its version is not the same as the application was developed with.
So I push the code which should go to Google Store and update the service to bring the proper version on the device. Now this device does not have a service only a WiFi (meaning its just a piece of hardware, not the phone).
Now when I ran this code it goes to the Google Store and it continuously tries to find the appropriate .apk.
The code I pushed is as follows:
int res = GooglePlayServicesUtil.isGooglePlayServicesAvailable( getApplicationContext() );
if( res != ConnectionResult.SUCCESS )
{
try
{
GooglePlayServicesUtil.getErrorDialog( res, this, RQS_GooglePlayServices ).show();
}
catch( Exception e )
{
Utils.displayErrorDialog( this, e.getMessage() );
}
}
What am I missing? It should just be straight update.
Thank you.
My problem sounds related. I have installed Foursquare on my Android (Jelly Bean) and when I launch Foursquare it pops-up with, you must upgrade Google Play (sounds like what you are trying to do in your App). I then click on the button and it launches the GP Store to upgrade. The upgrade stops progressing at 54% completion. Consistently -- after multiple times. I am suspect of memory size, as my Android is SLOOOOOWWWW, under powered and low on memory.

Android Service Distribution

I have developed an android service. Any android app can use it's API's to get some kind of news updates from this service. I want to distribute this service so that any android app on the phone can use this service. My questions here are :
When some android application try to use its API on the phone and suppose that service is not available on the phone then what will happen ?
How will android application developer will make sure that the service is available on the phone ?
Does application developer has to bundle service with his application ? If yes then wont be there multiple instances of same service on phone if multiple application contains same service on the phone ?
Thanks
Dalvin
When some android application try to use its API on the phone and suppose that service is not available on the phone then what will happen?
If they are smart, they will use PackageManager to see if you are installed first. Otherwise, their attempt to call startService() or bindService() will fail.
How will android application developer will make sure that the service is available on the phone ?
Use PackageManager.
Does application developer has to bundle service with his application?
How are we supposed to know? You are the person who wrote it.
If yes then wont be there multiple instances of same service on phone if multiple application contains same service on the phone ?
Possibly. It is difficult to answer this question in the abstract, as there are multiple ways to distribute this service (as an APK, as an Android library project, as a JAR, as just a hunk of source code) and multiple ways to integrate it (change the source code, use the source/JAR/library as-is, reference the existing APK).

Categories

Resources