当前位置: 编程技术>移动开发
本页文章导读:
▪在contacts中增添自定义mime type 在contacts中添加自定义mime type
public void saveFormality() {
try {
ContentValues values = new ContentValues();
values.put(Data.DATA1, this.getFormality() ? "1" : "0");
int mod = ctx.getContentRes.........
▪ 透过 group id 获得联系人的姓名 通过 group id 获得联系人的姓名
String where = ContactsContract.CommonDataKinds.GroupMembership.GROUP_ROW_ID + "="
+ groupid + " AND "
+ ContactsContract.CommonDataKinds.GroupMembership.MIMETYPE + "='"
.........
▪ Uri发起图片跟一个网址 Uri发起图片和一个网址
1.ImageView.setImageUri(Uri.fromFile(new File("/sdcard/cats.jpg"))); ImageView.setImageUri(Uri.parse(new File("/sdcard/cats.jpg").toString()));
2.String url = "http://almondmendoza.com/android-applications/"; Intent.........
[1]在contacts中增添自定义mime type
来源: 互联网 发布时间: 2014-02-18
在contacts中添加自定义mime type
public void saveFormality() {
try {
ContentValues values = new ContentValues();
values.put(Data.DATA1, this.getFormality() ? "1" : "0");
int mod = ctx.getContentResolver().update(
Data.CONTENT_URI,
values,
Data.CONTACT_ID + "=" + this.getId() + " AND "
+ Data.MIMETYPE + "= '"
+ clsContacts.FORMALITY_MIMETYPE + "'", null);
if (mod == 0) {
values.put(Data.CONTACT_ID, this.getId());
values.put(Data.MIMETYPE, clsContacts.FORMALITY_MIMETYPE);
ctx.getContentResolver().insert(Data.CONTENT_URI, values);
}
} catch (Exception e) {
Log.v(TAG(), "saveFormality failed");
}
}
public boolean getFormality() {
if (data.containsKey(FORMALITY)) {
return data.getAsBoolean(FORMALITY);
} else {
// read formality
Cursor c = readDataWithMimeType(clsContacts.MIMETYPE_FORMALITY, this.getId());
if (c != null) {
try {
if (c.moveToFirst()) {
this.setFormality(c.getInt(0) == 1);
return (c.getInt(0) == 1);
}
} finally {
c.close();
}
}
return false;
}
}
上面的是添加了一个boolean在联系人中,2.1以上适用
[2] 透过 group id 获得联系人的姓名
来源: 互联网 发布时间: 2014-02-18
通过 group id 获得联系人的姓名
String where = ContactsContract.CommonDataKinds.GroupMembership.GROUP_ROW_ID + "="
+ groupid + " AND "
+ ContactsContract.CommonDataKinds.GroupMembership.MIMETYPE + "='"
+ ContactsContract.CommonDataKinds.GroupMembership.CONTENT_ITEM_TYPE + "'";
Cursor c = this.ctx.getContentResolver().query(
ContactsContract.Data.CONTENT_URI,
new String[] {
ContactsContract.CommonDataKinds.GroupMembership.RAW_CONTACT_ID,
ContactsContract.Data.DISPLAY_NAME
}, where, null, ContactsContract.Data.DISPLAY_NAME + " COLLATE LOCALIZED ASC");
do {
if (c.getLong(groupIdx) == id) {
Cursor ccur = ctx.getContentResolver().query( Phone.CONTENT_URI,
new String[] {Phone.NUMBER, Phone.TYPE,
Phone.DISPLAY_NAME },
Phone.CONTACT_ID +"="+ contactId,
null, null);
Log.e("Test: Number", ccur.getString(0))
Log.e("Test: Name", ccur.getString(2))
}
} while (c.moveToNext());
[3] Uri发起图片跟一个网址
来源: 互联网 发布时间: 2014-02-18
Uri发起图片和一个网址
1.ImageView.setImageUri(Uri.fromFile(new File("/sdcard/cats.jpg")));
ImageView.setImageUri(Uri.parse(new File("/sdcard/cats.jpg").toString()));
2.String url = "http://almondmendoza.com/android-applications/";
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
最新技术文章: