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
Related
It seems like from the various tutorials ive seen people would jump from one activity to another by calling intents from the activity they are working on.
ex:intent(this, anotheractivity.class)
sometimes I see people just using the class they are going to as the parameter
ex: intent (android.content.blahblahblah)
whats the difference in functionality?
is the second made for default classes?
help is much appreciated
There are two "types" of Intents. One is called and explicit Intent in which you tell Android the specific class you are trying to reach (i.e. MyClass.class). The other case uses Android's filtering system to give you the best "match" for the Class you are targeting. When you call new Intent(String action) you are specifying an action to match with some IntentFilter. If your app shares the IntentFilter with some other app, then a dialog will pop up so the user can select which app he/she wants to use.
As illustrated by a number of questions here, it's sometimes difficult to get intent filters configured correctly. If a filter is not working like expected (e.g., app shows "permission denied"), what are some tricks to figure out why?
Update: To clarify, I'm not just talking about built-in intents. It's been a struggle getting a custom OAuth callback URL to resolve to the correct activity, but I can't tell if the issue is due to my intent filter or something else.
Option 1: Catch-all IntentFilter, then debug IntentFilter.match()
I wanted to ask exactly the same question. I know of no readily available tools for debugging failing intent filters but this is the approach I'm thinking of:
Make the intent filter as permissive as possible (i.e. put wildcards everywhere you can) so that you can grab and examine the Intent from within your application
Submit the Intent object thus obtained to your real intent filter's match method. You should be able to tell at which stage matching failed by looking which NO_MATCH_* constant is returned.
Once you captured the Intent you can also run the matching in a debugger so better understand what is wrong.
Option 2: Use the App Links Assistant
(This option only works if you want to debug http/https links)
Make sure the App Links Assistant plugin is enabled (File > Settings > Plugins > check "App Links Assistant" in the list). Restart Studio if prompted
Open the assistant (Tools > App Links Assistant)
Click "Open URL Mapping Editor" button in the side bar
Create/Edit your IntentFilter in the dialog
Type a test url in the "Check URL Mapping" box.
This will not tell you why a filter does not work, but allows much faster trial-and-error testing. That's what allowed me to understand why my filter wouldn't work (turns out we can't put wildcards in the "port". I set scheme to http, host filter to *, left port number empty (tried * as well) and set a pathPattern, but it would only matcĥ port 80 (on arbitrary hosts)
First - check if called component is declared in the parent manifest for the calling component.
If the called component is yours and not in the same app, check if it is declared in its own manifest.
Other possible problem - if the called component is correct by itself (broken layouts, forbidden elements in a widget)
Some intent-filters are protected by the system. And as such would require you to have a permission before you can use it. The trick is to know what you want. Once you know what you want, then you can look up intent filters that are available.
The preferred option would be to learn the traverse the android source code and find what you're looking for in the manifest.
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.
I'm working on my first Android application, and am trying to get an Intent for the QuickContact panel. Somewhere I had found mention of the method QuickContact.getQuickContactIntent(...). But when I try to use it, it tells me that it is undefined for the type QuickContact. After googling for several days, I find a bunch of pages using it in code, but nothing about how to use it or what imports are necessary or anything. So how do I use this method? I need to get the Intent used to launch the panel.
I've included the following import in my file:
import android.provider.ContactsContract.QuickContact;
Alternatively, what other method could I use to get a QuickContact intent for passing to something expecting an intent? I am looking to pass the intent back in the cursor for a LiveFolder provider.
I am developing against the Google APIs Level 9, platform number 2.3.1.
Thanks!
Use the widget onUpdate() and onRecieve() events to communicate with the RemoteView like explained here. The documented source of that discussion is here if you want some reading material. I can't begin to assume why you're trying to get the intent, or how you initially created the ContactContract.QuickContact object you're referring to. Little more information might get a few more views, and probably alternate solutions; so if this doesn't help consider posting a bit more info.
Well, the way I got this to work was to instead abandon the idea of using LiveFolders, and write my own "folder" dialog, to which I can add actual QuickContactBadge widgets using an adapter of my own devising.
What's the proper way for other people to reuse my Activities? Should they hard code the intent actions in their app or is it customary to provide them with a jar file enumerating my app's intent actions? Is there a less tightly-coupled way to lookup the intent actions?
First of all, take a look at openintents.org and see if there's any match to what your activity does.
Secondly, documentation is always a good idea.
Having the intent details hardcoded in their applications should work just fine. After all, the intents are part of your public interface and shouldn't change.
Your applications manifest should announce what sorts of things your activity can handle, via intent-filters. Outside users can read the manifest to determine what actions you support, and invoke them via action intents.
See intents and intent filters for more details.