What does this symbolise with reference to Intents? - android

I've read the following for Android Intents:
Think of Intents as a verb and object; a description of what you want done –
E.g. VIEW, CALL, PLAY etc.
I am not able to understand this sentence. Can anyone please explain me this? I know that An Intent is an abstract description of an operation to be performed.

I will try and explain. You use an Intent when you want a particular activity in your application to do something. The action that you want to perform is specified as the Intent itself (Like play music, call someone, take a photo). Verbs are something which represent any action. Intents also represent actions that you app will do with the help of activities and intents.
Also intents always need an object to perform the desired action which is an argument in the Intent. Hence the destination class object in the Intent is the is description (it contains all the detailed methods of the operation to be performed).
Hope it helps!!!

Intent transport infomation between 2 Activity, amagine it's like a transporter send mail, gift, information... between you and I.
So, I want to send you a PhoneNumber and I need you call this number. So the transporter need your name, address,... (--> It's like setClassName() in Intent) and action i want you do (--> like ACTION in Intent). After that, the transporter will send infomation to you and you will call the phonenumber for me.

Related

How can I know the startActivity intent from other application?

I have an Activity and assume that has been launched. When the other application use startActivity method to start my Activity, my Activity will show and run the onResume Method, but I can't find any way to get the intent which is used in startActivity method by the other application. I want to get the extra data in the intent. How can I do?
EDIT
My Activity is singleTask, and I want to get the startActivity intents form other applications. I think it is not associate with filters.
Have you tried using getIntent() ?
Then you can do:
this.getIntent().getExtras();
After that if you need new intents just override the onNewIntent function in your activity.
I simply say an example. When we need to share something. We click share button which shows a list of app by which we can share our things.
So, if you want to make that kind of app which can receive other app data then you need make your activity capable of receiving that data. In order to receive implicit intents, you must include the CATEGORY_DEFAULT category in the intent filter in manifest.
Below this link you will get some more information : http://developer.android.com/training/basics/intents/filters.html

android- how to trigger notification onclick event? or how to get data only when user clicks on it

I have an app that has a notification generator. I'm able to receive and generate multiple notifications. my problem now is how can I know which notification that was clicked by user? each notification might act differently, and there might be at most 5 notifications at the same time in my app. I've searched online and found nothing about onClick event with notification....
I found thatonNewIntent can help, but it is not stable...since the activity might get killed by system before user clicks the notification.
can someone please help??
thanks!!
I suggest you make add data to the intent you add to the notification's intent.
For example.
intent.putExtra("Notification_id", id) //You can make this id the system time or some unique identifier.
(Or you can add this to your bundle of extras instead of just putting the extra.)
Then when you go to open the intent you can check the id.
id = intent.getExtra("Notification_id")
Hope this helps. Let me know if you have any questions or need more details.
UPDATE: You have to add data for in the intent and read it later both in your onNewIntent() and onResume(). You then remove the extra from the intent after you did whatever it is you need to do. Also adding some kind of unique data like System.currentTimeMillis() then it will prevent the intent from being reused.

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.

android incoming call screen

I would like to add details to the incoming call screen on android.
lets say I have a string 'x', so I want 'x' to show up on the incoming call screen under the name of the person who is currently calling.
I know this is possible because of these apps:
CallerId,
Vringo
I'm pretty new to this area, so I need to know what is the process to achieve that, for example: get the event of incoming call, go to the incoming call interface and so on.
Thanks!
I think you have to look at the intent receivers (actually called intent filter => have to be defined in your manifest), there should be one for incoming calls. And then you define your own application, with an activity that is made to receive this kind of intent and with the design you like...
if i'm not mistaken, it should be this :
ACTION_ANSWER
you can find more doc here and there.
CallerId seems to show Toast on the Call screen or they maybe use WindowManager addView methods (i think Vringo is working in a such way). The most problem in such case is to know that Call Screen is now on the foreground.

Categories

Resources