国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
Android中Context簡介
Context字面意思是上下文,位于framework package的android.content.Context中,其實該類為LONG型,類似Win32中的Handle句柄。很多方法需要通過 Context才能識別調(diào)用者的實例:比如說Toast的第一個參數(shù)就是Context,一般在Activity中我們直接用this代替,代表調(diào)用者的實例為Activity,而到了一個button的onClick(View view)等方法時,我們用this時就會報錯,所以我們可能使用ActivityName.this來解決,主要原因是因為實現(xiàn)Context的類主要有Android特有的幾個模型,Activity以及Service。
Context提供了關(guān)于應用環(huán)境全局信息的接口。它是一個抽象類,它的執(zhí)行被Android系統(tǒng)所提供。它允許獲取以應用為特征的資源和類型。同時啟動應用級的操作,如啟動Activity,broadcasting和接收intents。
下面介紹Context的一些get方法,通過這些get方法可以獲取應用環(huán)境全局信息:
1.public abstract Context getApplicationContext ()
Return the context of the single, global Application object of the current process.
2.public abstract ApplicationInfo getApplicationInfo ()
Return the full application info for this context's package.
3.public abstract ContentResolver getContentResolver ()
Return a ContentResolver instance for your application's package.
4.public abstract PackageManager getPackageManager ()
Return PackageManager instance to find global package information.
5.public abstract String getPackageName ()
Return the name of this application's package.
6.public abstract Resources getResources ()
Return a Resources instance for your application's package.
7.public abstract SharedPreferences getSharedPreferences (String name, int mode)
Retrieve and hold the contents of the preferences file 'name', returning a SharedPreferences through which you can retrieve and modify its values. Only one instance of the SharedPreferences object is returned to any callers for the same name, meaning they will see each other's edits as soon as they are made.
8.public final String getString (int resId)
Return a localized string from the application's package's default string table.
9.public abstract Object getSystemService (String name)
Return the handle to a system-level service by name. The class of the returned object varies by the requested name. Currently available names are:
還有很多有用的方法,具體不一一列舉。詳情請參考文檔,反正Context很有用。
 
本文來自CSDN博客,轉(zhuǎn)載請標明出處:http://blog.csdn.net/zhangqijie001/archive/2010/09/17/5891682.aspx
本站僅提供存儲服務,所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報。
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
使用 SharedPreferences
解析activity之間數(shù)據(jù)傳遞的方法
SharedPreferences數(shù)據(jù)共享
Android中Context詳解
Android應用Preference相關(guān)及源碼淺析(SharePreferences篇)
監(jiān)聽Android應用程序是否卸載成功
更多類似文章 >>
生活服務
分享 收藏 導長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服