Android Common URI

Source: Internet
Author: User

Some URIs about contacts:

To manage the URI of a contact:

ContactsContract.Contacts.CONTENT_URI

The URI of the phone that manages the contact:

ContactsContract.CommonDataKinds.Phone.CONTENT_URI

To manage the URI of the contact's email:

ContactsContract.CommonDataKinds.Email.CONTENT_URI

(Note: Contacts has two tables, namely rawcontact and data,

Rawcontact records the user's ID and name,

Where the ID column name is: contactscontract.contacts._id, the Name column is ContactContract.Contacts.DISPLAY_NAME,

The foreign key ID of the telephone information table is ContactsContract.CommonDataKinds.Phone.CONTACT_ID,

The phone number column name is: ContactsContract.CommonDataKinds.Phone.NUMBER.

The name of the email address bar in the data table is:
ContactsContract.CommonDataKinds.Email.DATA
The key bar is: ContactsContract.CommonDataKinds.Email.CONTACT_ID)

Some URIs about multimedia:

Audio files stored on the SD card:

MediaStore.Audio.Media.EXTERNAL_CONTENT_URI

Audio files stored on the phone's internal memory:

MediaStore.Audio.Media.INTERNAL_CONTENT_URI
Image file contents on SD card:

MediaStore.Audio.Images.EXTERNAL_CONTENT_URI

Pictures on the phone's internal memory:

MediaStore.Audio.Images.INTERNAL_CONTENT_URI

Video on SD card:

MediaStore.Audio.Video.EXTERNAL_CONTENT_URI

Video on your phone's internal memory:

MediaStore.Audio.Video.INTERNAL_CONTENT_URI

(Note: The display name of the picture bar: Media.display_name,

The detailed description column for the picture is: media.description

Where to save the picture: Media.data

SMS URI:

Content://sms

SMS URI in the Send box:

Content://sms/outbox

Message URI in the inbox:

Content://sms/sent

Text message URI in draft:

Content://sms/draft

Common code:

Query contacts in Contacts?
cursor cursor = getcontentresolver (). query (ContactsContract.Contacts.CONTENT_URI, NULL, NULL, NULL, and NULL);

Get phone number
Cursor phone = cursor.query (ContactsContract.CommonDataKinds.Phone.CONTENT_URI, NULL, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + "=" + ContactId, NULL, NULL);
Complex points:
Cursor phone = cursor.query (ContactsContract.CommonDataKinds.Phone.CONTENT_URI, NULL, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + "=" + ContactId + "+" + ContactsContract.CommonDataKinds.Phone.TYPE + "=" + ContactsContract.CommonDataKinds.Phone.TYPE_MOBILE, NULL, NULL);
ContactsContract.CommonDataKinds.Phone.TYPE represents the type of contact phone,

The main correspondence is as follows:
Type_mobile: Mobile phone number
Type_home: Residential Phone
Type_work: Company Phone

Open a Web page, the category is Intent.action_view

Uri uri = Uri.parse("http://www.baidu.com/");

Intent intent = newIntent(Intent.ACTION_VIEW, uri);

Open the map and navigate to a point

Uri uri = Uri.parse("geo:52.76,-79.0342");

Intent intent = newIntent(Intent.ACTION_VIEW, uri);

Open dial-up interface, type is intent.action_dial

Uri uri = Uri.parse("tel:10086");

Intent intent = newIntent(Intent.ACTION_DIAL, uri);

Call directly, unlike this, this calls directly, not the dial-up interface.

Uri uri = Uri.parse("tel:10086");

Intent intent = newIntent(Intent.ACTION_CALL, uri);

To uninstall an app, the intent category is Intent.action_delete

Uri uri = Uri.fromParts("package""xxx"null);

Intent intent = newIntent(Intent.ACTION_DELETE, uri);

To install the application, the intent category is intent.action_package_added

Uri uri = Uri.fromParts("package""xxx"null);

Intent intent = newIntent(Intent.ACTION_PACKAGE_ADDED, uri);

Play audio files

Uri uri = Uri.parse("file:///sdcard/download/everything.mp3");

Intent intent = newIntent(Intent.ACTION_VIEW, uri);

intent.setType("audio/mp3");

Open the Outgoing mail interface

Uri uri= Uri.parse("mailto:[email protected]Android-study.com");

Intent intent = newIntent(Intent.ACTION_SENDTO, uri);

e-mail, the difference is to send the message out

Intent intent = newIntent(Intent.ACTION_SEND);

String[] tos = { "[email protected]"};

String[] ccs = { "[email protected]"};

intent.putExtra(Intent.EXTRA_EMAIL, tos);

intent.putExtra(Intent.EXTRA_CC, ccs);

intent.putExtra(Intent.EXTRA_TEXT, "I come from http://www.android-study.com");

intent.putExtra(Intent.EXTRA_SUBJECT, "http://www.android-study.com");intent.setType("message/rfc882");

Intent.createChooser(intent, "Choose Email Client");

Send a message with an attachment

Intent intent = newIntent(Intent.ACTION_SEND);

intent.putExtra(Intent.EXTRA_SUBJECT, "The email subject text");

intent.putExtra(Intent.EXTRA_STREAM, "file:///sdcard/mysong.mp3");

intent.setType("audio/mp3");

startActivity(Intent.createChooser(intent, "Choose Email Client"));

Texting

Uri uri= Uri.parse("tel:10086");

Intent intent = newIntent(Intent.ACTION_VIEW, uri);

intent.putExtra("sms_body""I come from http://www.android-study.com");

intent.setType("vnd.Android-dir/mms-sms");

Send text messages directly

Uri uri= Uri.parse("smsto://100861");

Intent intent = newIntent(Intent.ACTION_SENDTO, uri);

intent.putExtra("sms_body""3g android http://www.android-study.com");

Send MMS

Uri uri= Uri.parse("content://media/external/images/media/23");

Intent intent = newIntent(Intent.ACTION_SEND);

intent.putExtra("sms_body""3g android http://www.android-study.com");

intent.putExtra(Intent.EXTRA_STREAM, uri);

intent.setType("image/png");

# Market Related

 

1   ; //Find an app

uri uri = uri.parse ( "Market://search?q=pname:pkg_name" );

Intent it =  new   Intent (Intent.action_view, URI);

startactivity (it);

//where Pkg_name is the full package path to an application

2   //display information about an app

uri uri = uri.parse ( "market://details?id=app_id" );

Intent it =  new   Intent (Intent.action_view, URI);

startactivity (it);

//where app_id is the application ID, find the ID

//by Clicking on your application on the market home

//page, and notice the ID from the address bar

Path planning

Uri uri = Uri.parse("http://maps.google.com/maps?f=d&saddr=startLat%20startLng&daddr=endLat%20endLng&hl=en");

Intent it = newIntent(Intent.ACTION_VIEW, uri);

startActivity(it);

//where startLat, startLng, endLat, endLng are a long with 6 decimals like: 50.123456

Install the specified apk

publicvoidsetupAPK(String apkname){

    String fileName = Environment.getExternalStorageDirectory() + "/"+ apkname;

    Intent intent = newIntent(Intent.ACTION_VIEW);

    intent.setDataAndType(Uri.fromFile(newFile(fileName)),"application/vnd.android.package-archive");

    mService.startActivity(intent);

}

Go to contact page

Intent intent = newIntent();

intent.setAction(Intent.ACTION_VIEW);

intent.setData(People.CONTENT_URI);

startActivity(intent);

View specified contacts

Uri personUri = ContentUris.withAppendedId(People.CONTENT_URI, info.id);// info.id联系人ID

Intent intent = newIntent();

intent.setAction(Intent.ACTION_VIEW);

intent.setData(personUri);

startActivity(intent);

Call album

publicstatic finalString MIME_TYPE_IMAGE_JPEG = "image/*";

publicstatic final intACTIVITY_GET_IMAGE = 0;

Intent getImage = newIntent(Intent.ACTION_GET_CONTENT);

getImage.addCategory(Intent.CATEGORY_OPENABLE);

getImage.setType(MIME_TYPE_IMAGE_JPEG);

startActivityForResult(getImage, ACTIVITY_GET_IMAGE);

Call the System camera application and store the captured photos

Intent intent = newIntent(MediaStore.ACTION_IMAGE_CAPTURE);

time = Calendar.getInstance().getTimeInMillis();

intent.putExtra(MediaStore.EXTRA_OUTPUT, Uri.fromFile(newFile(Environment

.getExternalStorageDirectory().getAbsolutePath()+"/tucue", time + ".jpg")));

startActivityForResult(intent, ACTIVITY_GET_CAMERA_IMAGE);

<uses-permission android:name= "Android.permission.READ_CONTACTS"/>

Android Common URI

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.