what is capablity of component in android - android

can anybody tell what is capablity of component in android.I know intent filter is capablity of component.can anybody explain what is that?
thanks

An Intent object is a bundle of information. It contains information of interest to the component that receives the intent (such as the action to be taken and the data to act on) plus information of interest to the Android system (such as the category of component that should handle the intent and instructions on how to launch a target activity).

Related

How to redirect from own application another application?

I am creating my own app and at one point I want that user can go to any other application.So what will be the best code for that?
You can do that in many ways, but one of the common method is intents. You can create implicit intents for this purpose.
here is a sample code :
//From MainActivity.onCreate()
Intent intent = new Intent(Intent.ACTION_VIEW,Uri.parse("http://google.com"));
startActivity(intent);`
you can find further details about intents here.

Invoke system contact app and retrieve data android

Im developing an application where in I have 2 text views and a button.
when I click the button, it should open default system contacts application and upon selecting a contact, it should display the name and number in the text fields respectively.
Now I have implemented ContactsContract and getContentResolver. But, I have seen other apps having this feature, which is quite easy because you need not create a list view and stuffs.
Now how do I start? how do I invoke default contact app and retrieve data from it.
I don't know the details about your problem, but I am pretty sure that you need to use an Implicit Intent (because the Contacts app may be different on different devices). Hopefully this page will help.
You may need to start by using this code:
Intent i = new Intent(); // Declare intent
// Start the intent
startActivity(i);
You may want to use ACTION_GET_CONTENT.
Thanks for the replies. I found out that this is what i need.
Intent localIntent = new Intent("android.intent.action.PICK",ContactsContract.Contacts.CONTENT_URI);

Open my application from another in android

My boss asked me to prove that my application behaves properly when summoned by another application (dunno why he asked that).
So I have two apps here, one launches a second one. How I launch the specific app I want? Using Intent launch seemly any generic app that reaches a certain goal, not the app I really want.
Give this a try.
Intent secondIntent = new Intent();
secondIntent.setAction(Intent.ACTION_MAIN);
secondIntent.setClassName("com.example", "com.example.YourSecondApp");
startActivity(secondIntent);
I should point out that com.example should be the package of your second application (the one you want to call) and com.example.YourSecondapp is the class name where you have your onCreate() method.
Intent secondApp = new Intent("com.test.SecondApp");
startActivity(secondApp);
Check out for more examples
http://developer.android.com/resources/faq/commontasks.html#opennewscreen
Create one Intent using the following code
Explicit Intent
When you know the particular component(activity/service) to be loaded
Intent intent = new Intent();
intent.setClass("className/package name");
start<Activity/Service>(intent);
Imlicit Intent
When we do not have the idea which class to load and we know the Action to be perform by the launched application we can go with this intent.
Action needs to set, and the Android run time fallows the intent Resolution technique and list out(one or more components) the components to perform the action. from the list out components (if more than one), user will get the chance to launch his chosen application

Intent from Android Notepad example

action: android.intent.action.PICK
data: content://com.google.provider.NotePad/notes
Asks the activity to display a list of the notes under content://com.google.provider.NotePad/notes. The user can then pick a note from the list, and the activity will return the URI for that item back to the activity that started the NoteList activity.
action: android.intent.action.GET_CONTENT
data type: vnd.android.cursor.item/vnd.google.note
Asks the activity to supply a single item of Note Pad data.
The above is directly from Android Notepad example.
My question is, why have they defined two intent actions that perform the same task?? When will one or the other action be performed?
Also in the code, they have defined
String action = getIntent().getAction();
if (Intent.ACTION_PICK.equals(action) || Intent.ACTION_GET_CONTENT.equals(action)) {
Could someone please clarify, when will an action be set and on ListItemClick how will getAction resolve to either ACTION_PICK or ACTION_GET_CONTENT
Thanks in advance
My question is, why have they defined two intent actions that perform the same task?
They are not the same task. Quoting the documentation for ACTION_GET_CONTENT:
This is different than ACTION_PICK in that here we just say what kind of data is desired, not a URI of existing data from which the user can pick. A ACTION_GET_CONTENT could allow the user to create the data as it runs (for example taking a picture or recording a sound), let them browser over the web and download the desired data, etc.
When will one or the other action be performed?
When somebody calls startActivity() with an Intent containing one of those two actions, plus a content Uri pointing to this application (in this case).
Could someone please clarify, when will an action be set
It is set in the Intent used with the startActivity() call that was used to start the activity.
how will getAction resolve to either ACTION_PICK or ACTION_GET_CONTENT
By executing the code you included in your question.

Trapping filtered Intents from android

From my understanding, if an intent is invoked implicitly, android matches the intent object's contents against all intent filters in the following order: component, action, data and category, filtering out non-matching intents at each step. At this point if there are multiple intents filtered out, then it brings up the activity chooser.
Is there a way by which I can trap the final filtered result and do further filtering based on Extras and Flags? Would ResolveInfo be of any help to me in this case?
In effect, I want to process my custom logic before android brings up the Activity chooser.
Can someone please point me in the right direction, maybe a place in the android source code which helps me to do the above?!
Thanks a lot!
If you are the one calling startActivity(), you can use PackageManager and queryIntentActivities() to find out what the chooser would wind up showing. You can then roll your own chooser if you, er, choose.
If you are trying to intercept the starting of any and all activities on the device, this is not possible.

Categories

Resources