Android open Contacts app (not choose a contact) - android

I want to give the user possibility to open Contacts app from my app, so he can edit them, export etc. What I DON'T WANT is a contact picker where the user selects a contact. I need only to somehow open the Contacts app from my app. How Can I do it ? Intent ?

The following snippet will do what you want .
Intent intent = new Intent(Intent.ACTION_VIEW, ContactsContract.Contacts.CONTENT_URI);
startActivity(intent);

This should work as expected.
Intent intent = new Intent();
intent.setComponent(new ComponentName(
"com.android.contacts"
,"com.android.contacts.DialtactsContactsEntryActivity");
startActivity(intent)

Related

Is it possible to update emergency contact programatically?

I am able to make a call using,
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setData(Uri.parse("tel:" + "911"));
startActivity(intent);
But I am required to update emergency contact in Android programatically from my app. Is there any way to update emergency contact from any app other than from default contact app? By update I mean add, delete and modify any emergency contact.
Here is one post, where they discussed how to update contact, but in my case, I need to update the emergency contact not a normal contact.
There is no way to modify emergency information until now. However any app can ask user to edit info using ACTION_VIEW or ACTION_EDIT.
Intent intent = new Intent(Intent.ACTION_VIEW, ContactsContract.Profile.CONTENT_URI);
MainActivity.this.startActivity(intent);

How to open the default android browser without specifying an URL?

I'm loosing my mind over this. I want to open the user's default web browser. I can use this:
startActivity( new Intent( Intent.ACTION_VIEW, Uri.parse("http://google.com")));
To open the browser and send the user to that URL. But I don't want to send him to a specific URL, I just want to open the browser. I'm sure it's a simple solution, I just can't find it. Any Ideas?
To just open the browser without any URL opened you can use
startActivity( new Intent( Intent.ACTION_VIEW, Uri.parse("about:blank")));
After a bunch of searching, I was able to do this:
PackageManager pm = getPackageManager();
Intent queryIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.google.com"));
ActivityInfo af = queryIntent.resolveActivityInfo(pm, 0);
Intent launchIntent = new Intent(Intent.ACTION_MAIN);
launchIntent.setClassName(af.packageName, af.name);
startActivity(launchIntent);
It basically says "What application would handle this?". Then it grabs that applications package and class name then fires an intent for the main action.

Is there a way to direct the user to the market for another app?

I want to direct the user from one app the user is currently running, to the market, to download another app.
The link to the market is: market://search?q=pname:your.package.name
use this in your code:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse("market://details?id=com.android.example"));
startActivity(intent);
from: http://developer.android.com/guide/publishing/publishing.html#marketintent
Yes. Try this:
Intent intent = new Intent(Intent.ACTION_VIEW,
Uri.parse("https://market.android.com/details?id=com.hg.cyberlords"));
c.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
c.startActivity(intent);
This will open the market app with "Cyberlords" app.

How to open phonebook from android application?

I am working on android app in which I want to open phonebook on button click event. Will I have to use intent for that?
Thanks,
Vishakha.
Try something like this:
Intent intent = new Intent(Intent.ACTION_PICK, ContactsContract.Contacts.CONTENT_URI);
startActivityForResult(intent, PICK_CONTACT);
To get more into this see Android – Open Contacts Activity and Return Chosen Contact

Option to create new contact from pick list

My application wants a functionality of picking a contact from the
phone contact, I have achieved this using the following intent
Intent intent = new Intent(Intent.ACTION_PICK, People.CONTENT_URI);
startActivityForResult(intent, 001);
How do i start pick contact activity with an option to create a new contact from the pick list, similar to the one which is available in inbuilt Launcher appliation.
Perhaps passing in one of the extras listed in Contacts.Intents.UI. I'm mostly looking at LIST_ALL_CONTACTS_ACTION and LIST_DEFAULT.

Categories

Resources