也许有人可以帮助我。我想将两个字符串传递给另一个活动。这是我生成的字符串代码:将字符串传递给Android中的另一个活动
private void contactPicked(Intent data) {
Cursor cursor = null;
try {
String phoneNo = null;
String name = null;
// getData() method will have the Content Uri of the selected contact
Uri uri = data.getData();
//Query the content uri
cursor = getContentResolver().query(uri, null, null, null, null);
cursor.moveToFirst();
// column index of the phone number
int phoneIndex = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER);
// column index of the contact name
int nameIndex = cursor.getColumnIndex(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME);
phoneNo = cursor.getString(phoneIndex);
name = cursor.getString(nameIndex);
// Set the value to the textviews
textView1.setText(name);
textView2.setText(phoneNo);
} catch (Exception e) {
e.printStackTrace();
}
我想PHONENO和名称传递给我的MainActivity
我试图做一个SharedPreference和我MainAcitivity加载DefaultSharedPreference没有任何结果
的可能的复制[您如何传递数据/参数,在Android的另一个活动(http://stackoverflow.com/questions/6340423/how-do-you-pass-data-parameters-到另一个活动在Android) – starkshang