- ./adb -s MX1CA16BLCYPDA1959 shell 当有多个调试设备时需要用s选项指定设备
- 在使用ImageView时要注意到
android:src
和android:background
的不同, 前者可以在保持比例的条件下调整图像,后者则会使图像变形以完全充满背景;android:
scaleType可以设置图像的调整方式,如居中或者全部填充等;android:
adjustViewBounds=true可以使imageview调整自己的边界去适应图像 - 在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(); } }