标签:over 信息 receiver data- 动作 mil tcl puts activity
最近看了一篇文章,把Android划分成为一个王国,主要为分为以下
双十一刚过,我们还是来说说这个强大的物流运输公司吧
// 内部类
classMyOnclickListenerimplementsView.OnClickListener{
@Override
publicvoid onClick(View view){
switch(view.getId()){
case R.id.btn_activity:
Intent intent =newIntent();
intent.setClass(MainActivity.this,OtherActivity.class);
intent.putExtra("name","ZhangSan");
Bundle bundle =newBundle();
bundle.putInt("age",12);
bundle.putString("address","北京朝阳双龙南里18-1701");
intent.putExtra("bundle", bundle);
startActivity(intent);
break;
}
}
}
Intent intent = getIntent();
Bundle bundle = intent.getBundleExtra("bundle");
tv_show.setText("name:"+ intent.getStringExtra("name")+"\n"+
"age:"+ bundle.get("age")+"\n"+"address:"+ bundle.get
("address"));
privatestaticfinalint REQUEST_CODE =1001;
......
Intent intentResult =newIntent(OtherActivity.this,ResultActivity.class);
startActivityForResult(intentResult, REQUEST_CODE);
@Override
protectedvoid onActivityResult(int requestCode,int resultCode,Intent
data){
super.onActivityResult(requestCode, resultCode, data);
if(requestCode == REQUEST_CODE){
if(resultCode == RESULT_OK){
tv_result.setText(data.getStringExtra("result"));
}
}
Intent intent = getIntent();
intent.putExtra("result","我是Activity的结果");
setResult(RESULT_OK,intent);
// RESULT_OK 是Activity的常量finish();
findViewById(R.id.btn_sendSMS).setOnClickListener(newView
.OnClickListener(){
@Override
publicvoid onClick(View view){
Intent intent =newIntent();
intent.setData(Uri.parse("smsto:10086"));
intent.setAction(Intent.ACTION_SENDTO);
intent.putExtra("sms_body","10086,你好,我是测试发送的短信");
startActivity(intent);
}
});
Intent intent =newIntent(Intent.ACTION_PICK,
ContactsContract.Contacts.CONTENT_URI);
startActivityForResult(intent, PICK_CONTACT_REQUEST);
if(requestCode == PICK_CONTACT_REQUEST){
Cursor cursor =null;
if(resultCode == RESULT_OK){
Uri uri = data.getData();
ContentResolver resolver = getContentResolver();
if(uri !=null){
cursor = resolver.query(uri,newString[]{ContactsContract.Contacts.DISPLAY_NAME},null,null,
null);
}
String name =null;
if(cursor.moveToFirst()){// True if the cursor is not empty
int columnIndex = cursor.getColumnIndex(ContactsContract.Contacts.DISPLAY_NAME);
name = cursor.getString(columnIndex);
et_contacts.setText(name);
}
}
}
标签:over 信息 receiver data- 动作 mil tcl puts activity
原文地址:http://www.cnblogs.com/his365/p/6058249.html