- startActivity() or startActivityForResult()
-
- startActivityForResult():被调用的活动B会向其调用者A返回信息,B用setResult方法设定返回信息,A用onActivityResult方法得到返回的信息,(该onActivityResult的方法在上一个activity结束后,本activity onStart之后,onResume之前)
- setResult(int resultCode) setResult(int resultCode, Intent data)
- onActivityResult(int requestCode, int resultCode, Intent data)
- resultCode: RESULT_CANCELED, RESULT_OK, RESULT_FIRST_USER....或者用户自定义
- startService() or bindService()
- sendBroadcast(), sendOrderedBroadcast(), or sendStickyBroadcast().
<action android:name="android.intent.action.SEND" />
<data android:type="*/*" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
Caution: Over time, new restrictions may be added to the platform such that, in order to use certain APIs, your app must request a permission that it previously did not need. Because existing apps assume access to those APIs is freely available, Android may apply the new permission request to the app's manifest to avoid breaking the app on the new platform version. Android makes the decision as to whether an app might need the permission based on the value provided for the targetSdkVersion
attribute. If the value is lower than the version in which the permission was added, then Android adds the permission.
For example, the WRITE_EXTERNAL_STORAGE
permission was added in API level 4 to restrict access to the shared storage space. If your targetSdkVersion
is 3 or lower, this permission is added to your app on newer versions of Android.
Beware that if this happens to your app, your app listing on Google Play will show these required permissions even though your app might not actually require them.
targetSdkVersion
to be as high as possible. You can see which permissions were added with each release in the
Build.VERSION_CODES
documentation.
- 语言:res-> values ->strings.xml res-> values-es ->strings.xml res-> values-fr ->strings.xml。调用@string/name
- 屏幕尺寸:大小(small, normal, large, xlarge)和密度(ldpi, mdpi, hdpi, xhdpi)。创建不同大小的图片库,res -> drawable-xhdpi -> XXX.png。 调用@drawable/name。 注意,ldpi通常不需要指定,系统会自动根据hdpi的图片,减半来适应。
- 横竖屏状态:layout->默认竖屏,layout-land ->
- 版本:
-
- AndroidMainifest.xml文件中,<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="15" />
- 【安卓系统会自动忽略当前版本不支持的xml中属性,所以使用起来是安全的】在运行的时候检查API是否支持,如ActionBar,支持android3.0以上(API11),例如:
- Styles和Themes:可以借用安卓的库,使app始终有最新的look;或者自定义样式。
private void setUpActionBar() { // Make sure we're running on Honeycomb or higher to use ActionBar APIs if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) { ActionBar actionBar = getActionBar(); actionBar.setDisplayHomeAsUpEnabled(true); } }
- onCreate(Bundle savedInstanceState) 方法中实现的东西包括:
- onStart()实现细节:
-
- 下载应用状态(如拉取邮件更新)
- onStop() ,onDestroy() 可能不会被调用
- 所以,如果要保存状态,应该在onPause()方法中实现。