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 :-)
Related
i create my TWA app based on this repo: https://github.com/GoogleChromeLabs/svgomg-twa
I would like to extend the code with In-App Review https://developer.android.com/guide/playcore/in-app-review
Is it possible to do this? I am front-end developer. I have no knowledge of android application
Maybe i can listen to url change? For example in html create anhor
Rate app now!
and app listen and check current hash in location.
Nowadays, I'd recommend using #bubblewrap/cli to bootstrap the Trusted Web Activity project, as svgomg-twa has been deprecated and replaced by Bubblewrap.
In short, yes, it is possible to integrate in-app-reviews in a Trusted Web Activity.
The general approach is to use a custom schema, like my-app:// that is handled by an Android Activity. This Activity will, in turn, launch the review flow and then finish itself.
There are some caveats though:
You'll need to check if the all is in "trusted web activity mode" in order to display the link, as it only works when inside a Trusted Web Activity.
This may also not be compatible with Chrome OS, so if you are also deploying the Trusted Web Activity there, I wouldn't recommend integrating in-app reviews.
Here's a blogpost with more details on how to do it.
Illustration:
How do I pass data coming from a form in my app to a third-party app?
Also, what are the terms, functions and APIs about doing this?
It is possible through Intent and URI.
The app that is receiving your data should support be open to receive URI so that you can fire up the Intent method it will open the app and send data.
You can refer: https://developer.android.com/training/basics/intents/sending.html#java
Unfortunately there is not a one-size-fits-all solution to this question, as such you are going to receive a variety of different "solutions" but the truthful answer is, it depends on the implementation of the app built by the other party;
Intents
If the third-party app is open to receiving data through intents, and hopefully the developer of that app has documented this somewhere. This would be the most streamlined approach.
It is important to note with this implementation that if there are specific apps you have in mind to connect to, and your application is going to be publicly available, then the user will need to have those specific third-party apps installed. This is easier if you only have one specific third-party app in mind (you can check the user's device to see if it is installed and inform them), and gets exponentially more cumbersome for every additional application you wish to connect to, not only due to having to instruct the user about yet another required third-party app but also as you will need to make sure you are able to pass all the necessary data to a completely different application.
Have a look at this earlier question to see how this can be achieved.
APIs
Another solution would be to use APIs. Just like intents, this requires the third-party developer to have exposed their application to these specific API calls, which you can then connect to to pass your data. The simplest real-world implementation of this approach would be signing on to an application using a social media account instead of having to create a separate account per application.
This is less streamlined than the intents approach as it would involve additional steps of posting your data to the API and then opening the other app in order to retrieve the data and proceed.
So I just did a bit digging and found out that storing any type of passwords in any java application (in my case, android application) is not safe as the password can be retrieved by anyone by decompiling the java code. Now, on net, I, somewhere, also learned that a better way to interact with any database (my case), such as mysql, would be to create a web interface which by some way can differentiate between anyone else interacting without my app and someone interacting with web interface through my app. So, can someone tell me how to do so or if there is any better way to accomplish what I want to?
for this you can check out firebase to interact with database and create your web application and mobile application based on that data . And there you can differentiate in them.
One way which you already know is to create a web service layer which accesses your database.
Another way would be to use a BaaS to have a direct web layer access to a backend. There are many available BaaS solutions which would help you with this.
Third and best way in my opinion for new coders would be to use an existing auth service like Firebase Auth. This will pretty much give you all the features out of the box eg... signup emails,password resets, multiple login methods and their Firebase Auth UI will give you login screens without almost any code. Check it out, it actually is pretty good if it suits your needs
Maybe chrome custom tabs are what you're looking for? They let you open an instance of chrome from within the app https://developer.chrome.com/multidevice/android/customtabs
We have a case where we want to navigate between apps, case where
triggering a payment will open the payment app
once the payment is complete it should navigate back to the original app.
I have found few theoretical solution for (1), can use Android Intent(I hope I'm right here), or use services like https://deeplink.me. Which navigate to the payment app, I assume here that I can pass some complex data along with the request to navigate to the correct page on my app.
For problem 2, I'm yet identify a solution, Do I have include Intent filter in the source app too? say the source app uses the payment app's sdk and is there a way I could pass back the response an HTTP response which the source app can use to navigate to the right page (payment success or failure).
You are correct: an Android Intent can be used to open another app (documentation). Facebook's Applinks standard can also do this, as can the Branch.io service (amongst many other things). Deeplink.me AppWords is a neat concept, though it appears to be bid-based and I can't see a way to open a specific app on demand.
However, unless there is a need to use an external app for this, why not just integrate something like the Stripe Android SDK, or PayPal's braintree SDK or native SDK directly into your app? That way you don't even have to worry about passing data around externally and you retain end-to-end control of the process. Seems like a far more elegant solution!
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.