首页 > 其他 > 详细

打电话和发短信

时间:2015-02-04 00:45:14      阅读:266      评论:0      收藏:0      [点我收藏+]

一,拨打电话

 

 

  lv.setOnItemClickListener(new OnItemClickListener() {

 

                              @Override

                              public void onItemClick(AdapterView<?> parent, View view,

                                                  int position, long id) {

                                        //添加意图

                                        Intent intent = new Intent();

                                        //添加动作

                                        intent.setAction(intent.ACTION_CALL);

                                        //添加数据

                                        intent.setData(Uri.parse("tel:"+phones[position]));

                                        startActivity(intent);

                              }

                    });

注意:添加拨打电话的权限

 

 

三,发送短信

lv.setOnItemLongClickListener(new OnItemLongClickListener() {

 

                              @Override

                              public boolean onItemLongClick(AdapterView<?> parent, View view,

                                                  int position, long id) {

                                         

                                         Intent i=new Intent(getApplicationContext(), SmsActivity.class);

                                         i.putExtra("number", phones[position]);

                                         startActivity(i);

                                         

                                        return true;

                              }

                    });

注意:短信的权限

作为初学者,增加权限最容易忘记了

本文出自 “xmy” 博客,请务必保留此出处http://88649164.blog.51cto.com/9890093/1611274

打电话和发短信

原文:http://88649164.blog.51cto.com/9890093/1611274

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!