Having issues with my apps on Google Play. I have a free app which utilizes a custom permission. This permission allows access to paid apps. These paid apps act as "keys" and unlock features in the free app. Basically the free app will attempt to start the intent of one of the paid apps. The paid app will do some stuff and return saying whether the free app should unlock features or not.
Problem arises based on the order of app installation. If the free app is installed first then a paid app, the free app can't start the intent. Returns permission denial. If the paid app is installed first then the free app, the free app can start the intent no problem. Rebooting the device and/or force stopping the apps doesn't resolve the issue. I'm attaching the relavent code. Something tells me I'm doing something incorrectly.
Free App Manifest (relevant code):
...
<uses-permission android:name="com.company.license.PERMISSION" />
...
Free App Code to check intent (relevant code):
Intent KeyApp = new Intent("com.company.license.action.AUTH_1");
KeyApp.putExtra("com.company.license.challenge", 1);
//If free app is installed first, an exception is thrown for not having the proper permission. If paid app is installed first, no exception is thrown
try {
startActivityForResult(KeyApp, COMMING_FROM_KEYAPP);
} catch (Exception e) {
cancelStartUp();
}
Paid App Manifest (relevant code):
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.company.installer.1"
...
<permission
android:name="com.company.license.PERMISSION"
android:icon="#drawable/icon"
android:label="#string/app_name"
android:protectionLevel="normal" >
</permission>
<application
android:icon="#drawable/icon"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoDisplay" >
<activity
android:name="com.company.license.auth"
android:configChanges="keyboardHidden|orientation"
android:exported="true"
android:permission="com.company.license.PERMISSION"
android:theme="#style/Theme.Transparent" >
<intent-filter>
<action android:name="com.company.license.action.AUTH_1" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name="com.company.installer.redirect"
android:configChanges="keyboardHidden|orientation"
android:exported="true"
android:theme="#style/Theme.Transparent" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
Put the same <permission> element in both apps. Also, since this is specific to your two apps, I would use android:protectionLevel="signature" instead of normal -- this means the user will never need to approve the permission and nobody else will be able to request the permission. And, this recipe will allow installation in either order.
UPDATE: Note, however, that the use of custom permissions opens up potential vulnerabilities, due to Android's "first one in wins" approach.
UPDATE #2: And this is now no longer supported as of Android 5.0, as two apps cannot both have the same <permission> element unless they are signed by the same signing key.
I was able to work around the issue #CommonsWare mentioned in his Update #2. Simply by only declaring the permission in the app which will be installed first.
Explanation:
I have app A and app B, signed with different signatures. App A needs to use app B to login, but app A gets installed first and makes sure the user installs app B.
Because app B seems to be the (login)service I declared the custom permission in app B. App B has a (intent)service which other apps may use, as long as they use the permission and are in our whitelist. So app B had the service and permission declared.
But because app A is installed before app B I discovery I needed to add the permission as well to app A. Otherwise app A didn't seem to have the permission after installing app B. My best guess is that this is because the permission stuff is done at installation. And since app A didn't declare the permission, at install nothing happened. But then app B is installed which has the permission but app A still doesn't receive this permission.
But then I tested on Android 5 and ran into their unique permission changes. So I tested some flows and permission declarations and came up with a working solution:
Declare the custom permission in the app that gets installed first! Of course this only work when you know which app is going to be installed first. But in my case, where app A is dependant on app B ánd app A installs app B, this was the solution :)
Related
Having seen the questions about activities with no GUI here, here and here. In addition, these answer are rather old, I don't know if they're still relevant.
I want to create an app for which the only user interaction is a quick tile.
I understood there can't be no activity at all, so I have a blank activity with no display using #android:style/Theme.NoDisplay
<activity
android:name=".MainActivity"
android:label="#string/app_name"
android:theme="#android:style/Theme.NoDisplay">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<service
android:name=".AdaptativeSleepTile"
android:icon="#drawable/ic_launcher_background">
</service>
But the app appears in my app list (with nothing happening when I click it, logically), which is not what is written in the comments of this answer.
I can't remove the line <category android:name="android.intent.category.LAUNCHER"/> otherwise I get the error message
Could not identify launch activity: Default Activity not found
Error while Launching activity
So what should I do to have a service for which the only user interaction is the quick tile? (Same question would also apply for no interaction at all, or only widget I guess)
Using Android Studio 4 and Sdk 29
I want to create an app for which the only user interaction is a quick tile.
That may or may not be practical. Since Android 3.1, apps are installed in a "stopped state", and it takes an explicit Intent to move them out of the stopped state and allow them to run. Normally, that comes from the user tapping on an icon in a launcher to run your MAIN/LAUNCHER activity.
It is possible that simply having a TileService available in the manifest is enough to get you listed in the notification shade, and the act of adding the tile will be enough to move your app out of the stopped state. However, I certainly cannot guarantee that, and it would not surprise me if this does not work.
Also, please bear in mind that you may need an activity for other reasons:
To display your terms of service
To display your privacy policy
To provide access to tech support
To allow for configuration of the app
And so on
But the app appears in my app list (with nothing happening when I click it, logically), which is not what is written in the comments of this answer.
If you mean the first comment, that is simply wrong, as is pointed out by other comments on that answer.
I can't remove the line otherwise I get the error message
I assume that you are getting that from Android Studio. You will need to change your run configuration to not try starting an activity.
Same question would also apply for no interaction at all
Fortunately, there is no solution for that. Malware authors think that totally invisible apps are wonderful, and Android takes steps to prevent such apps from being able to work. And, this is why I would not be surprised if you need an activity for your TileService.
I'm trying to create an .aar file to be used by other applications. In this module, the user needs to go out of the application due to the payment. I want to open the application after the payment is finished and a button on the website is clicked. If it was in my application, I could easily handle it by adding an intent-filter for deep linking in manifest. But now I don't know how I can read manifest and read the deep link defined on the application.
I searched for it and I couldn't find any answer.
Thanks in advance.
You can add an Activity to your Android module (library) and define the same intent-filter in the manifest for your Activity.
So when the browser is done with payment flow they can fire up your library's Activity Using Deep-Links.
I highly suggest to read up on Android App Links as well.
This way you can handle everything right in your .aar and end App developers don't have to play the relay role for you.
There is one important catch with this approach and that is to be careful when multiple applications have integrated your .aar on the same device.
In that case after the payment flow, Android will suggest to the user both of the apps, which is wrong and might lead to an unexpected result.
There is a simple fix to this by using $applicationId key in the intent-filter defined for your Activity.
Just make sure your browser will call the correct callback-URL with the correct applicationId when it's done.
Here is a complete sample of that Activity manifest:
<activity
android:name=".CallBackActivity"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" />
<data android:host="www.yourDomainName.com" />
<data android:pathPattern="payment/$applicationId" />
</intent-filter>
</activity>
--Use case:
1-System app apk in priv-app folder to be used as device owner.
2-User starts up device and Google setup wizard comes up.
3-Immediately starts device provisioning activity.
--Things that used to work:
This method used to work on Android 6.0 Marshmallow using the action intent:
<activity android:theme="#style/InvisibleNoTitle" android:name="OwnerActivity" android:launchMode="singleTop" android:immersive="true">
<intent-filter android:priority="5">
<action android:name="android.intent.action.MAIN" />
<action android:name="android.intent.action.DEVICE_INITIALIZATION_WIZARD" />
<category android:name="android.intent.category.HOME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
without any problem.
After updating to Android 8.1 Oreo, this method no longer works. The OwnerActivity shows up only after setup wizard finishes which is useless since device is already provisioned by user and can't be provision again.
Is there any newer way of doing this so that my OwnerActivity shows up first to provision the device? What is changed in Oreo?
This is a bit late for an answer, and without talking to Google it's a little hard to see what the design decisions have been. However, what we can know is what's changed.
1. android.intent.action.DEVICE_INITIALIZATION_WIZARD is deprecated atleast as early as Oreo.
2. Package Manager Service has had changes to reference the setup wizard. The new approach appears to be the category android.intent.category.SETUP_WIZARD which your manifest definition lacks.
Reading the comments around the code (which you can find below) we see this log:
Slog.e(TAG, "There should probably be exactly one setup wizard; found " + matches.size()
+ ": matches=" + matches);
https://android.googlesource.com/platform/frameworks/base/+/nougat-mr2.3-release/services/core/java/com/android/server/pm/PackageManagerService.java#17872
So it seems like as of Nougat, Android doesn't support having multiple setup wizards that are chained together.
For your specific problem of how to setup the device admin I have 2 suggestions.
If you care about CDD and CTS then you should get your users to go through the Google device owner provisioning process which they keep updated.
If you don't care about that and you just want your build to always have a device owner, just make changes in the frameworks or add some system binary that always runs before the setup wizard which will set your device owner application for you.
I'm trying to launch my Android App, using deep linking. Basically, the users will receive emails with links, when the user clicked the link, the App should launch.
I know how to do the basic deep linking, however, I want to launch the actual App not just a specific activity. My deep linking scheme is something like "mydeeplinking" and in the email is like "mydeeplinking://".
I am looking for Something similar to the iOS deep linking, which launch the entire App.
Any help would be appreciated.
Thanks in advance.
Basically, all you need to do is use intent-filter to tell Android what type of data should be routed to your app.
AndroidManifest.xml:
<activity android:name="com.example.MainActivity" >
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" />
<data android:scheme="https" />
<data android:host="www.example.com" />
<data android:path="/" />
<data android:path="/map" />
</intent-filter>
</activity>
This will launch your MainActivity when the user clicks any of these links:
http://www.example.com/
https://www.example.com/
http://www.example.com/map
https://www.example.com/map
Deep linking is greatly enhanced by Firebase. It's a little hard to get started, but it works great! Check this link for an example.
Comparing this deep linking to iOS is where the confusion may come in, because theirs works differently. Android has always been able to push information from one app to another and even pull from the web, which is what iOS is doing. That isn't deep linking per-se. It can go MUCH further than that- it is meant to provide a personalized app experience even before a user creates a profile (or something similar). It's also important to note that deep linking holds onto this personalized info even through the installation of an app and opens the app with whatever that info was! It's not just an intent! Your question has to do with URI schemes. Maybe this will help if you still agree that you're looking for deep linking.
If you are simply looking to launch an app (already installed on the users device or not), intent filters are the way to go, and intents can pass information. If you are wanting a user to use an activity in an app without ever installing it, android instant apps is the right choice. If you're looking for a way to pass information "deeply" from the user's email or internet to your app, deep linking is advised.
Intent filters can be used to open some apps from web pages. When a link is selected that could be opened in a browser or in an app (or multiple apps), a box will pull up from the bottom of the phone's screen, asking for the user's preference for the default to open in on future clicks. (see image below) The web site's javascript may have to be altered to detect the user's operating system and send the proper URL call. iOS works a little differently.
Here is how to use an intent filter. It has some extra code that you may find useful..
public void startNewActivity(Context context, String packageName) {
Intent intent = context.getPackageManager().getLaunchIntentForPackage(packageName);
if (intent == null) {
// brings user to the market if app is not installed already
intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id=" + packageName));
}
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); // opens a new "page" instead of overlapping the same app
context.startActivity(intent);
}
If you need to pass data at the same time, use intent.putExtra("name", "value");
My app runs and installed fine on my GenyMotion emulator device. However after I launch the app on the emulator and press the back button, I don't see the app on the Android app browse screen. Here is what I see in the app browse screen.
And I know this app is installed because when I go to settings -> Apps, here is what I see(Demo-App-)
Is there a reason why the app won't show up on the app browse screen? I didn't have this issue when I used eclipse(with android plugin). Is the issue with some setting in Android Studio 1.0? I like a quick way of starting the app and testing it without having to run it from Android Studio each time.
I tried looking on other threads but couldn't find the issue
The issue can't be android app doesn't show on the emulator because my app installed fine.
Thanks to Egor's comment, When I looked closely at my Android Manifest, here's what I saw
<intent-filter>
<action android:name="android.intent.action.MAIN"
android:category="android.intent.category.LAUNCHER"
/>
</intent-filter>
category should be its own tag, that is
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>