Intent details used to open the current Android app - android

Is there a way to find out from the just-opened app, from within, what were the intent details used to open the current app?
Sample scenario:
The app can have multiple activities, I would like to know which one was requested when the app process starts, e.g. from Application.onCreate.

Related

Xamarin.Forms Android Applications start 2 processes after use share intent

Currently, I app developing an application which uses share intent. but when I share a file to my app, my application starts another process.
Steps to reproduce.
start the application.
go to gallery/file manager.
select a file and share to the current application.
Show list applications are running.
Result:
My application starts in two different processes (Please see the screenshot)
I got the answer. It needs android:launchMode="singleTask/singleInstance" in the activity.

Android: How to register for intent iff another condition is met

I have two apps on the play store . Both of them handle an intent and run a service based on it.
However I do not want them to compete and if both are installed I only want App A to show in the Android App chooser and not App B.
How would I keep App B from trying to handle the intent if App A is installed?
Android handles intents internally so when you say an activity is registered for handling an intent it will most likely be via Action field.
If you want two activities to have the same action and to suppress one Activity from showing in Chooser, then it is not possible unless you modify the Android OS.
However I do not want them to compete and if both are installed I only want App A to show in the Android App chooser and not App B
Activities do not "compete" for starting up, its usually the user who chooses which activity to start when an action is specified. So if you want AppA to only show in the chooser, you can declare a different action for AppB.
Hope this helps!

Start another application in my own layout

i'm building an application and need a layout that shows another application, there is any way to open the another app from in my own application?
(i don't want an intent to open the normal app, I want to open it from in my application)
I need that because my layout have some good animation(for example, fade in and out every 20 sec)
for example -
You cannot start another application within your application. this is now how android works. The only option you have is to start the application using an intent.
From Android documentation: https://developer.android.com/training/articles/security-tips.html
The Android Application Sandbox, which isolates your app data and code execution from other apps.

How do I build a wrapper (or launcher and receiver upon completion) for an external app in Android?

I'm working with a partner who has an app (App A) that wishes to call my app (App B). Once called App A will then wait for App B to finish what it's doing and collect some data.
In the exact scenario I'm working in, App A collects user info (name, phone) and then needs to pass it to App B. App B will do some stuff with that info and when finished, needs to notify App A that it succeeded (or didn't succeed) to perform operations for user name_phone.
What do our apps need to know about each other for this to work?
I'm looking at startActivityForResult but I'm getting the impression that's something one would use within ones own application and not something App A can use to launch App B.
TIA
startActivityForResult() works fine between applications. You should take a look at Barcode Scanner by ZXing to see how they use startActivityForResult() for this very purpose.
App B will need to have an Activity with an <intent-filter> that will be stable, such as one using a custom action string. App B will also need to document what the Intent should look like (e.g., required action, required Uri if any, extras), and what will be returned via onActivityResult().
The author of App B could create a JAR file that provides a cleaner API for App A to use. ZXing did that with Barcode Scanner.

Launching Android app, within an app?

I'm writing a basic application. One of the features I'm interested in trying to do is to launch another app, INSIDE the app already running.
Eg. I have an app with 3 menu options, 1 and 2 do certain tasks as part of this parent app, menu option 3 launches another app that's installed on the phone.
I'm not sure if this is possible?
This is possible with the Intents mechanism.
The exact Intent you'll have to write depend on various factors:
do you have to provide some data to the launched application?
do you target a specific application or do you want to let the user choose the application he prefers for that task (in case he has several applications able to do what you need)?
do you want to ensure that the application is available? (that would be better)
do you know if the other app provides specific intent-filters to do some tasks?
Edit:
Then, you should be able to start the second application with the following code:
Intent i = new Intent(Intent.ACTION_MAIN);
i.addCategory(Intent.CATEGORY_LAUNCHER);
i.setPackage("com.otherapp.package");
startActivity(i);
Place this code in the OnClickListener of your button and that should be enough.

Categories

Resources