6.DDMS视图和Button

在eclipse 里的Emulator Control 可以发短信和打电话挂电话。中文乱码是因为模拟器的问题。

button的getId方法:

button.getId() ;//得到R.id.btn

实现button事件:实现OnClickListener

7.Intent初级学习

1.Intent 程序跳转和传递参数都要使用。

2.拨打电话:

Intent intent = new Intent();intent.setAction(Intent.ACTION_CALL);//设置打电话的动作,(也可设置发短信等等)intent.setData(Uri.parse("tel:110"));//设置电话号码startActivity(intent);//启动

还需要配置打电话的权限。

修改文件:AndroidManifest.xml,在<manifest></manifes>中间加入

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

3.发短信:

intent.setAction(Intent.ACTION_SENDTO);intent.Uri.parse("smsto:5554");intent.putExtra("title",'body');startActivity(intent);

需要权限

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

4.两个窗口切换

//发送intent.putExtra("key","value");//这里可以发送序列化对象//另一个Activity,接收Intent intent = getIntent();Bundle bundle = intent.getExtras();bundle.getString("key");

5.关闭新窗口

public final static int RESULT_CODE=1;//在新窗口关闭后会回调。startActivityForResult(intent,REQUEST_CODE)//关闭回调的方法protected void onActivityResult(int requestCode,int resultCode,Intent data){if(requestCode==REQUEST_CODE){        if(resultCode==MainActivity.RESULT_CODE){            Bundle bundle = data.getExtras();            String value = bundle.getString("key");        }    }}//另一个Activity,结束操作Intent intent = new Intent();intent.putExtra("key","value");setResult(RESULT_CODE,intent);finish()

更多相关文章

  1. android发送http请求—-URLConnection、HttpURLConnection的使用
  2. Android设置Button字母大小写
  3. Android切换前后置摄像头并录制视频
  4. android实现为PreferenceScreen设置背景图片等
  5. Android(安卓)onConfigurationChanged 不执行
  6. Android设置输入法
  7. android中,如果使用imageButton可以在drawable 中设置一个selecto
  8. Android(安卓)动画学习 二
  9. PopupWindow软键盘弹出遮挡输入框

随机推荐

  1. Introducing home screen widgets and th
  2. android app 与电脑wifi通信(二)
  3. 图片内存溢出处理
  4. Android:使用TextureView预览Camera
  5. android 动态创建控件并设置布局
  6. Android下的Dialog
  7. How to use HTC on Ubuntu 12.04 to test
  8. android SDK/APP 涉及用户隐私需要关注的
  9. Android(安卓)OpenCV 安装与配置+JNI开发
  10. 《转载》android context 与内存泄露