Calling activity from another app that stores data - android

I am currently developing a set of three standalone Apps for Android. One of these Apps provides functionality that - if this App is installed on a device - can be called by the other two apps. This specific activity collects some data and stores it in an SQLite DB. Since I am rather new to Android development I'd like to know the following:
If I call an external activity from within my App, does this activity act as if it were still part of its "originating" App and thus accesses data managed by the originating App? That's what I think is happening but I want to be sure before I design my Apps that way.
Thanks for helping out
Sven

If I call an external activity from within my App, does this activity act as if it were still part of its "originating" App and thus accesses data managed by the originating App? That's what I think is happening but I want to be sure before I design my Apps that way.
this activity will run in its own process. This means that if its process was not yet created, then it will be created for this activity.
If you are the owner of all your apps and want them to share data you might be interested in this manifest option:
http://developer.android.com/guide/topics/manifest/manifest-element.html#uid
android:sharedUserId
The name of a Linux user ID that will be shared with other applications. By default, Android assigns each application its own
unique user ID. However, if this attribute is set to the same value
for two or more applications, they will all share the same ID —
provided that they are also signed by the same certificate.
Application with the same user ID can access each other's data and, if
desired, run in the same process.

Related

Sharing Data Between Android Apps By The Same Developer

We have a requirement to share some very simple data between Android apps, the data will basically just be a string but we want to ensure it's only shared between apps signed by us. The sharing of the data also needs to be programmatic i.e. without user interaction to initiate the sharing.
The issue we have with many of the data sharing methods we've found is that they imply the data is owned by one particular app which then makes it available to other apps. The data we need to share could be generated by any app so it doesn't have a natural owner.
Our ideal solution would be something similar to the Keychain on iOS where any app can write the data and any app can easily check if the data has already been written.
We have seen some solutions that involve setting a shared User ID for the apps but this appears to be deprecated in Android and also one of our apps is already in the store so the ID cannot now be changed.
Is anyone aware of any possible solutions on Android for this usecase?

Getting a View of current visible activity launched by other SDK

I am using a SDK (library like we use for payments or ads or some app which opens a webview), which is launching an activity. How Can I get the view instance of this activity which is launched by the SDK.
One method I know is to use ActivityLifeCycleCallbacks. But is there any other simple way to get this??
You can not. Android is a secure system and prohibits access to things you should not access.
In case of another app, it will be started as a separate process with no direct access and no access at all to things like views or Java objects. You should follow the documentation of the app developer, pass all data you need to pass in an Intent and await a response if needed.
In case of a library, you will not have access to Activities opened by it, as they are treated as closed components. It is possible that the developer created some sort of interface which would allow that, but there is no standard way to do this.
There is one workaround:
If the library is open source, you may choose to clone its repository and add the code locally to your app. This way you will be able to edit it and receive access to the components. But this will probably not work with secure things like payments or ads.
Again, just follow the documentation provided by the developer, be a good citizen :-)

In Android Can intents and broadcasts pass between user profiles

There seems to be limited documentation on this.
Im wondering if I have the same app installed in two different user profiles, and I fire an intent or broadcast applicable for that app, in one user profile, can the same app in the other user profile pick the broadcast or intent?
If so is this true for any android supported IPC such as binding etc...
Can anyone point me to good documentation on this?
The documentation you linked provides the information you need, implicitly though.
App. An application’s data exists within each associated user. App data is sandboxed from other applications within the same user. Apps within the same user can interact with each other via IPC. For details, refer to Building Apps for Work.
So you can't communicate with any app of another user.

How to embed a mobile application in other application?

I'm building a mobile application for a company and I need to add in the company mobile application a button that go directly in a different application .
Anyone know a solution to embed 1 mobile app in other app???
Inside the code of your button, you can launch an explicit/implicit intent that can launch another application (authored by someone else). The application won't be running inside your application, but to the user, he/she will have the illusion that the other application running is part of your own. This is assuming of course that the second application is already installed on the user's phone. If it isn't installed, your button can just fetch the relevant application's installation page from Google Play for the user to install the app, and then run the application once installed.
In your application, you can also provide a content provider to keep your data. A content provider provider exposes a set of public CRUD interfaces to your data for other applications to access. This is how the contacts database is shared on Android for instance between many different applications, even non-Google applications.
Basically, you first need start at the beginning and educate yourself on the fundamentals of Android. If you start reading about intents and content providers, those constructs may not make any sense to you until you first learn about Activities, the Activity's lifecycle, stacks/tasks, and the way security generally works on Android. You may even want to look on Youtube, there are some very good highly rated Google I/O videos on there that talk about the fundamental concepts of Android.

What happens if two android apps register the same custom URI schema?

I'm no Android-Developer but I need to know what happens, if two applications register the same URI schema (e.g. by using an intent-filter).
Is that possible at all?
In iOS it is. Multiple apps can register for the same URI schema. It can not be predicted which app will be launched when that schema is called. To make things worse, the app that is launched "consumes the event". So no other app will be noticing anything.
Background of my question:
I'm working on a "secure" concept for the implicit flow in OAuth 2.0.
This flow includes a redirect (comming from the server) to a URI schema.
Unfortunately, I can't use a WebView in the app, because the app mustn't have any possibility to gain access to the users credentials.
Is that possible at all?
Yes, at least for activities. When something tries to start an activity matching the scheme (and rest of the <intent-filter>, the user will get a "chooser" window, showing all possible activities, from which the user can choose.

Categories

Resources