I'm looking to open a calculator from within my Activity. Here's my code right now and it works:
Intent i = new Intent();
i.setClassName("com.android.calculator2",
"com.android.calculator2.Calculator");
I would like to make this an implicit call because I don't know what calculator the use would like to use and I would like to leave the option open to receive a value from the calculator, which the android one apparently doesn't do. I haven't been able to find a good example of how to implicitly ask for a type of application.
I've looked at http://www.openintents.org/en/intentstable but I guess I don't completely understand how to use that site.
I think I understand the intent of intents, but maybe I just don't have a firm grasp on how to use them.
What you have is probably the best you can do. I just checked the AndroidManifest.xml for com.android.calculator2.Calculator and it doesn't listen for any other intents.
Related
Firstly, I understand that commonly this is not something that you typically want to do. However, the app I'm developing adds functionality to another app, but requires that the other app be restarted for it to work.
Is it possible to restart another app (i.e. -> user clicks a confirm button, other app is closed and reopened)? How would I accomplish this?
If it's not possible normally, would it be possible if the app has SU? How would it be accomplished then?
I found a way that no need root permission.
ComponentName componentName = getPackageManager().getLaunchIntentForPackage("com.xxx.yyy.zzz").getComponent();
Intent intent = IntentCompat.makeRestartActivityTask(componentName);
startActivity(intent);
There are some ways to interact with other apps through Android. Usually, intents are used for this.
You can go through this tutorial that shows what are the possible things you can do with other apps using your activity.
Especially, see the Lesson: Sending the User to Another App
I was able to uncover an answer... hopefully this will be helpful to those of you looking for the same.
Using RootTools, this is very easily done.
RootTools.killProcess(package);
Intent LaunchIntent = getPackageManager().getLaunchIntentForPackage(package);
startActivity(LaunchIntent);
I want to add support for several navigation applications in my app. I know how to start another activity as intent and pass parameters - but is there any way to check the naming of the parameters I should pass? For example: Navigon should start with routing calculation and instructions immediately after starting from within my application. So far, I'm not even sure Navigon supports parameter passing, but I don't even know how to figure that out.
Thanks in advance!
You should check the documentation for each app you're interested in supporting. They should have it laid out somewhere. If they don't, they might not support explicit intent extras.
For example, Navigon has their options laid out here(found by searching "android navigon intent"):
http://www.navigon.com/portal/common/faq/files/online_documents/NAVIGON_Android_public_Intent.pdf
I have a webview in my app, on trying to do actions like making a call (Tapping call button from results displayed in webview), sending mails and other actions, my webview doesn't perform those actions
I Found a solution to add the intent actions in my web view activity as
Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse(url));
startActivity(intent)
Instead of doing so is there any way to add in the android manifest file
or Is there any way to turn on all of the intent actions for the webview so that
there wont be further issues in handling the actions
Can someone help me on this pls
Your answer seems to me a bit strange, I think you are a bit confuse about the difference between Intent and manifest permission. The first one are the system used by android to let app communicate with each other, the second one allow you to use some feature of the device like wifi and direct phone call that need the explicit agreement of the user to be used (the prompt that popup when you make the first install of an app).
With this clarification it is clear that if you want to do something that require another app you will have to make an Intent. This Intent, if well formed, will be elaborated by the os that will take care of sending it to the correct application able to accomplish the Intentrequirement.
So the answer to your question, as far as i know, is no, you have to use intent if you have the need of calling external app. It's also a good practice to set in the manifest only the permission really needed by the app, this way the user know what the app really can do and and what it can't do.
Hope i understand your question and answer it.
My question is, is it possible to call one app from another?
It would be very helpful if anyone had an answer or solution.
-Chris-
Yes, by using intents.
For example:
final Intent intent = new Intent();
intent.setAction(Intent.ACTION_MAIN);
intent.setClassName("com.example.theotherapp", "com.example.theotherapp.MainActivity");
startActivity(intent);
This is called an explicit intent, because you're explicitly stating which component should respond to it. You can also use implicit intents, in which you specify what kind of component you expect and the OS and/or the user selects the most appropriate one.
If you can choose, implicit intents are preferred.
You should take a look at http://developer.android.com/guide/topics/fundamentals.html, more specifically at the "Application Components" section.
There are many ways to make two applications talk to each other - and they're explained there.
My app needs to have a intent-filter that responds to a Intent that has it's component set (a explicit intent.) Here is a example.
Intent i = new Intent();
i.setClassName("com.compareeverywhere","com.compareeverywhere.ScanActivity");
startActivity(i);
Just a simple intent-filter will not do - because the Intent is made for a specific component (Activity,) it just launches that without looking for intents at all. Is there a way to do this?
Thanks, Isaac Waller
P.S: Please don't reply "No."
No.
:) That being said, imagine what would happen if Android allowed people to hijack Intents for specific components. Don't like a competitor's app? Just have yours hijack his main Activity with your own to display porn. Intents can specify specific components specifically because the authors don't want others to be able to replace them.
You have two options. If this is your own code, replace it with a generic intent, or if it belongs to someone else, contact them, and ask nicely for them to change it to a generic intent along with some good reasons why that is necessary.