I have created Intent chooser for my application. I want to send email and sms by this. My code is here http://pastie.org/8966227 . But I can get the result properly. The control always comes into second loop only. Any body can help me? thanks in advance.
You can't check which intent has user selected.
Unless you create your own implementation of the dialog for the activity selection.
To create such dialog you need to use PackageManager and its queryIntentActivities() function. The function returns List.
More information is available here and here.
Related
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);
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.
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.
I'm trying to implement a search fonctionality in my android app. With my app :
I click on the standard search button.
I
see the standard search dialog with
my icon app.
I see my list of suggests items app
when I type something in the search
field.
When I choose a suggest, something
call the onNewIntent of my standard
activity, but the intent is
*Intent.ACTION_VIEW*, not
*Intent.ACTION_SEARCH*, as I hope ??
I'm losted If it's ok to receive ACTION_VIEW, how I retreive the item searched ? If it's not ok, why ?
If it is the Intent.ACTION_VIEW, you can retrieve the data by using
intent.getData()
which will return a URI that you can parse.
Can you please tell me how can i open the android inbuilt View Contact Activity
Programatically.
I am having a list of contacts in my activity and i want to show the contact details on the selection of list Item, so i basically want to know to which android activity i should send the intent in order to open that activity.
Thanks in Advance.
Use the ACTION_VIEW action in your intent, with the content://contacts/people/1 URI (see javadoc of Intent for more details)
If you want to reach Contacts in Android, you probably want to read on in the Contacts class.