还有一个getResourceAsStream()方法,参数是与getResouce()方法是一样的,它相当于你用getResource()取得File文件后,再new InputStream(file)获取到输入流。 这两个方法最常用到的地方就是读取被配置文件,如数据库配置文件,日志配置文件等。
android.app.DownloadManager */ public abstract Object getSystemService(String name); public abstract int checkPermission(String permission, int pid, int uid); // 返回一个新的与application name对应的Context对象 public abstract Context createPackageContext(String packageName, int flags) throws Package...
2.1、ContextImpl是Context的具体实现类,实现了Context的所有功能。 2.2、ContextWrapper,通过字面就知道是一个Context的包装类,由于ContextWrapper就一个构造函数,且必须要传入一个Context,所以ContextWrap中持有有一个mBase变量的应用,通过调用attachBaseContext(Context)方法用于给ContextWrapper对象中mBase指定真正的Context...
它只是对Context类的一种封装,它的构造函数包含了一个真正的Context引用,即ContextImpl对象。 1/**2* Proxying implementation of Context that simply delegates all of its calls to3* another Context. Can be subclassed to modify behavior without changing4* the original Context.5*/6publicclassContextWrapper...
的主线程的Looper,此线程分发调用给应用组件(activities, services等)publicabstractLooper getMainLooper();//返回当前进程的单实例全局Application对象的ContextpublicabstractContext getApplicationContext();//从string表中获取本地化的、格式化的字符序列publicfinalCharSequence getText(intresId) {returngetResources()....
首先多进程情况下,Application 对象就不止一个;其次,Activity、Service、Application 继承自 ContextWrapper,它们自己就是一个 Context,里面又有一个 Base Context;最后,还有各种 outer context、display context 什么的,这部分没深入研究过,但 Context 的数量绝对大于上述等式的两倍了。
可以看到,ContextWrapper 实际上就是 Context 的代理类而已,所有的操作都是通过内部成员 mBase 完成的,另外,Activity、Service 的 getBaseContext 返回的就是这个 mBase。 ContextThemeWrapper 接着看 ContextThemeWrapper,这个类的代码并不多,主要看 Resource 和 Theme 相关的: ...
android:resource 指定AppWidgetProviderInfo的资源位置。 添加AppWidgetProviderInfo元数据。 AppWidgetProviderInfo定义了小组件的基本配置(例如最小布局尺寸、初始布局资源、更新频率、(可选)在创建时启动的配置Activity等)。使用单个元素在XML资源中定义AppWidgetProviderInfo对象,并将其保存在项目的res/xml文件夹中。
[Android.Runtime.Register("getAll", "(Ljava/lang/String;I)Landroid/media/EncoderProfiles;", "", ApiSince=31)] public static Android.Media.EncoderProfiles? GetAll(string cameraId, int quality); Parameters cameraId String the id for the camera. Numeric camera ids from the list received by...
参数说明:context(初始化SDK请传入Application的上下文对象)、config(初始化配置信息)、listener(初始化状态监听)。 setPersonalizedAdEnabled(boolean enablePersonalized) 设置个性化推荐开关。参数说明:enablePersonalized(true:开启,false:关闭, 默认:true)。 getPersonalizedAdEnabled() 获取个性化推荐状态,true:开启,false:...