Android实习笔记----调用拨号器,邮件短信和Google 地图

本文深入探讨了Android应用开发中的关键组件和交互操作,包括如何通过Intent调用系统功能,如拨打电话、发送邮件、查看地图等,以及如何在Android中高效地使用ImageView进行图像展示和调整。详细解释了Intent的使用方法、ImageView属性设置和操作,旨在为开发者提供全面的实践指导。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

  1. ./adb -s MX1CA16BLCYPDA1959 shell 当有多个调试设备时需要用s选项指定设备
  2. 在使用ImageView时要注意到android:srcandroid:background的不同, 前者可以在保持比例的条件下调整图像,后者则会使图像变形以完全充满背景;android:scaleType可以设置图像的调整方式,如居中或者全部填充等;android:adjustViewBounds=true可以使imageview调整自己的边界去适应图像
  3. 在Android下调用拨号程序或Google地图等比想象的要容易很多,使用Intent即可;
Intent geoIntent = new Intent(Intent.ACTION_VIEW);
geoIntent.setData(Uri.parse('geo:0,0?q=你的地址"));
try{startActivity(geoIntent);
} catch(ActivityNotFoundException e) {
    Toast.makeText(GeneratorActivity.this,R.string.noMapException, Toast.LENGTH_SHORT).show();
}


参见这一网页

http://developer.android.com/guide/appendix/g-app-intents.html

其他的操作如调用email,电话,短信等也基本同理,并不复杂:

//action="http://www.baidu.com"; //action="tel:df1234"; //action="sms:12334"; //action="mail:shang@nereide.fr"; //action="geo:48.849242,2.293024"; //action="geo: Société Néréide, 3b Les Isles 37270 Veretz, France"; if(action != null ) { if(action.startsWith("tel:")){ Intent callIntent = new Intent(Intent.ACTION_DIAL); callIntent.setData(Uri.parse(action)); startActivity(callIntent); }else if(action.startsWith("sms:")){ Intent callIntent = new Intent(Intent.ACTION_SENDTO); callIntent.setData(Uri.parse(action)); startActivity(callIntent); }else if (action.startsWith("mail:")){ Intent emailIntent = new Intent(Intent.ACTION_SEND); emailIntent.setType("message/rfc822"); emailIntent.putExtra(Intent.EXTRA_EMAIL,new String[]{action.substring(5)} ); emailIntent.putExtra(Intent.EXTRA_SUBJECT, "my subject"); emailIntent.putExtra(Intent.EXTRA_TEXT, "body text"); try { startActivity(Intent.createChooser(emailIntent, "Send mail...")); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(GeneratorActivity.this, R.string.noEmailClientException, Toast.LENGTH_SHORT).show(); } } else if (action.startsWith("geo")){ if( !action.startsWith("geo:0,0?q=")) { action = action.replaceFirst("geo:", "geo:0,0?q="); } Log.d(TAG, action); Intent geoIntent = new Intent(Intent.ACTION_VIEW); geoIntent.setData(Uri.parse(action)); try{startActivity(geoIntent); } catch(ActivityNotFoundException e) { Toast.makeText(GeneratorActivity.this, R.string.noMapException, Toast.LENGTH_SHORT).show(); } }





                
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值