零碎知识点总结
1.nevigation drawer总结,布局文件
public static final String QUERY
Intent extra data key: Use this key with content.Intent.getStringExtra() to obtain the query string from Intent.ACTION_SEARCH.
public Intent putExtra (String name, CharSequence value)
Add extended data to the intent. The name must include a package prefix, for example the app com.android.contacts would use names like "com.android.contacts.ShowAll".
See Also
- putExtras(Intent)
- removeExtra(String)
- getCharSequenceExtra(String)
-
if (intent.resolveActivity(getPackageManager())!= null ) {startActivity(intent);
}就是寻找符合条件的component
public ComponentName resolveActivity (PackageManager pm)
Added in API level 1Return the Activity component that should be used to handle this intent. The appropriate component is determined based on the information in the intent, evaluated as follows:
If getComponent() returns an explicit class, that is returned without any further consideration.
The activity must handle the CATEGORY_DEFAULT Intent category to be considered.
If getAction() is non-NULL, the activity must handle this action.
If resolveType(ContentResolver) returns non-NULL, the activity must handle this type.
If addCategory(String) has added any categories, the activity must handle ALL of the categories specified.
If getPackage() is non-NULL, only activity components in that application package will be considered.
If there are no activities that satisfy all of these conditions, a null string is returned.
If multiple activities are found to satisfy the intent, the one with the highest priority will be used. If there are multiple activities with the same priority, the system will either pick the best activity based on user preference, or resolve to a system class that will allow the user to pick an activity and forward from there.
This method is implemented simply by calling resolveActivity(Intent, int) with the "defaultOnly" parameter true.
This API is called for you as part of starting an activity from an intent. You do not normally need to call it yourself.
See Also
- setComponent(ComponentName)
- getComponent()
- resolveActivityInfo(PackageManager, int)
- int imageId=imageview.getIdentifier(String name,String defType,String defPack);该方法是通过image的名字,包名,类型,为drawable楼来得到image的资源定位符,暂且这么说吧。但前提是imag的名字与其在drawable文件夹中图片的名字必须是相同的,否则找不到。
-
public int getIdentifier (String name, String defType, String defPackage)
Added in API level 1Return a resource identifier for the given resource name. A fully qualified resource name is of the form "package:type/entry". The first two components (package and type) are optional if defType and defPackage, respectively, are specified here.
Note: use of this function is discouraged. It is much more efficient to retrieve resources by identifier than by name.
Parameters
name The name of the desired resource. defType Optional default resource type to find, if "type/" is not included in the name. Can be null to require an explicit type. defPackage Optional default package to find, if "package:" is not included in the name. Can be null to require an explicit package. Returns
- int The associated resource identifier. Returns 0 if no such resource was found. (0 is not a valid resource ID.)

浙公网安备 33010602011771号