當前位置: 首頁>>代碼示例>>Java>>正文


Java Context.getApplicationContext方法代碼示例

本文整理匯總了Java中android.content.Context.getApplicationContext方法的典型用法代碼示例。如果您正苦於以下問題:Java Context.getApplicationContext方法的具體用法?Java Context.getApplicationContext怎麽用?Java Context.getApplicationContext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.Context的用法示例。


在下文中一共展示了Context.getApplicationContext方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: DownloadHandler

import android.content.Context; //導入方法依賴的package包/類
/**
 * @param context                       上下文
 * @param fileDownloadTask              下載任務描述數據模型
 * @param absDownloadDir                一個帶有自定義規則的下載目錄(如:目錄是否會自動清理,目錄下的文件命名規範等)
 * @param baseDownloadNotifier          下載狀態監聽觀察者管理器
 * @param iFileAvailableChecker         任務下載完成後的檢查器,主要用於檢查下載完成的文件是否有效
 * @param isSupportMultiProcessDownload 是否支持多進程下載
 */
public DownloadHandler(Context context, FileDownloadTask fileDownloadTask, AbsDownloadDir absDownloadDir,
		DownloadPublisher baseDownloadNotifier, IFileAvailableChecker iFileAvailableChecker,
		boolean isSupportMultiProcessDownload) {
	mApplicationContext = context.getApplicationContext();
	mFileDownloadTask = fileDownloadTask;
	mAbsDownloadDir = absDownloadDir;
	mFileDownloadTask.setTempFile(mAbsDownloadDir.newDownloadTempFile(mFileDownloadTask));
	mFileDownloadTask.setStoreFile(mAbsDownloadDir.newDownloadStoreFile(mFileDownloadTask));
	mBaseDownloadNotifier = baseDownloadNotifier;
	mIFileAvailableChecker = iFileAvailableChecker;
	mIsSupportMultiProcessDownload = isSupportMultiProcessDownload;
	
	// 實質下載器
	mIDownloader = new AutoRetryDownloader(mApplicationContext, mFileDownloadTask);
}
 
開發者ID:youmi,項目名稱:nativead,代碼行數:24,代碼來源:DownloadHandler.java

示例2: testComponentCallbacksForTargetContext

import android.content.Context; //導入方法依賴的package包/類
@SmallTest
public void testComponentCallbacksForTargetContext() {
    Context targetContext = getInstrumentation().getTargetContext();
    Application targetApplication = (Application) targetContext.getApplicationContext();
    AdvancedMockContext context = new AdvancedMockContext(targetContext);
    Callback1 callback1 = new Callback1();
    Callback2 callback2 = new Callback2();
    context.registerComponentCallbacks(callback1);
    context.registerComponentCallbacks(callback2);

    targetApplication.onLowMemory();
    assertTrue("onLowMemory should have been called.", callback1.mOnLowMemoryCalled);
    assertTrue("onLowMemory should have been called.", callback2.mOnLowMemoryCalled);

    Configuration configuration = new Configuration();
    targetApplication.onConfigurationChanged(configuration);
    assertEquals("onConfigurationChanged should have been called.", configuration,
            callback1.mConfiguration);
    assertEquals("onConfigurationChanged should have been called.", configuration,
            callback2.mConfiguration);

    targetApplication.onTrimMemory(ComponentCallbacks2.TRIM_MEMORY_MODERATE);
    assertEquals("onTrimMemory should have been called.", ComponentCallbacks2
            .TRIM_MEMORY_MODERATE, callback2.mLevel);
}
 
開發者ID:lizhangqu,項目名稱:chromium-net-for-android,代碼行數:26,代碼來源:AdvancedMockContextTest.java

示例3: DrawerMenuAdapter

import android.content.Context; //導入方法依賴的package包/類
public DrawerMenuAdapter(Context context, int textViewResourceId, List<NavDrawerItem> objects) {
    super(context, textViewResourceId, objects);
    inflater = LayoutInflater.from(context);
    appContext = context.getApplicationContext();

    mInfoButtonListener = new View.OnClickListener() {
        @Override
        public void onClick(View pView) {
            pView.startAnimation(mBounceHelpButtonAnimation);
            if (pView.getTag() != null && pView.getTag() instanceof Integer) {
                showHelpToast((Integer) pView.getTag());
            }
        }
    };
    mBounceHelpButtonAnimation = AnimationUtils.loadAnimation(appContext, R.anim.action_button_help);
}
 
開發者ID:5GSD,項目名稱:AIMSICDL,代碼行數:17,代碼來源:DrawerMenuAdapter.java

示例4: initVideoView

import android.content.Context; //導入方法依賴的package包/類
private void initVideoView(Context context) {
    mAppContext = context.getApplicationContext();
    mSettings = new Settings(mAppContext);

    initBackground();
    initRenders();

    mVideoWidth = 0;
    mVideoHeight = 0;
    // REMOVED: getHolder().addCallback(mSHCallback);
    // REMOVED: getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
    setFocusable(true);
    setFocusableInTouchMode(true);
    requestFocus();
    // REMOVED: mPendingSubtitleTracks = new Vector<Pair<InputStream, MediaFormat>>();
    mCurrentState = STATE_IDLE;
    mTargetState = STATE_IDLE;

    subtitleDisplay = new TextView(context);
    subtitleDisplay.setTextSize(24);
    subtitleDisplay.setGravity(Gravity.CENTER);
    LayoutParams layoutParams_txt = new LayoutParams(
            LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT,
            Gravity.BOTTOM);
    addView(subtitleDisplay, layoutParams_txt);
}
 
開發者ID:lanyan520,項目名稱:Idea-ijkplayer,代碼行數:28,代碼來源:IjkVideoView.java

示例5: onAttach

import android.content.Context; //導入方法依賴的package包/類
@Override
public void onAttach(Context context) {
    super.onAttach(context);
    if (context instanceof TaskCallbacks) {
        mCallbacks = (TaskCallbacks) context;
    } else {
        throw new RuntimeException(context.toString()
                + " must implement TaskCallbacks");
    }
    mApplicationContext = context.getApplicationContext();
}
 
開發者ID:firebase,項目名稱:friendlypix-android,代碼行數:12,代碼來源:NewPostUploadTaskFragment.java

示例6: GoogleServicesManager

import android.content.Context; //導入方法依賴的package包/類
private GoogleServicesManager(Context context) {
    try {
        TraceEvent.begin("GoogleServicesManager.GoogleServicesManager");
        ThreadUtils.assertOnUiThread();
        // We should store the application context, as we outlive any activity which may create
        // us.
        mContext = context.getApplicationContext();

        mChromeSigninController = ChromeSigninController.get(mContext);
        mSigninHelper = SigninHelper.get(mContext);

        // The sign out flow starts by clearing the signed in user in the ChromeSigninController
        // on the Java side, and then performs a sign out on the native side. If there is a
        // crash on the native side then the signin state may get out of sync. Make sure that
        // the native side is signed out if the Java side doesn't have a currently signed in
        // user.
        SigninManager signinManager = SigninManager.get(mContext);
        if (!mChromeSigninController.isSignedIn() && signinManager.isSignedInOnNative()) {
            Log.w(TAG, "Signed in state got out of sync, forcing native sign out");
            signinManager.signOut();
        }

        // Initialize sync.
        SyncController.get(context);

        ApplicationStatus.registerApplicationStateListener(this);
    } finally {
        TraceEvent.end("GoogleServicesManager.GoogleServicesManager");
    }
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:31,代碼來源:GoogleServicesManager.java

示例7: create

import android.content.Context; //導入方法依賴的package包/類
/**
 * 創建finalbitmap
 * 
 * @param ctx
 * @return
 */
public static FinalBitmap create(Context ctx) {
	if (mFinalBitmap == null) {
		mFinalBitmap = new FinalBitmap(ctx.getApplicationContext());
		mFinalBitmap.init();
	}
	return mFinalBitmap;
}
 
開發者ID:PlutoArchitecture,項目名稱:Pluto-Android,代碼行數:14,代碼來源:FinalBitmap.java

示例8: setEnabled

import android.content.Context; //導入方法依賴的package包/類
public static void setEnabled(Context context, final Class<?> componentClass, final boolean
        enabled) {
    final Context appContext = context.getApplicationContext();
    executeOnFileIoThread(new Runnable() {
        public void run() {
            appContext.getPackageManager().setComponentEnabledSetting(new ComponentName
                    (appContext, componentClass), enabled ? 1 : 2, 1);
        }
    });
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:11,代碼來源:LeakCanaryInternals.java

示例9: EncryptedFileDataSourceFactory

import android.content.Context; //導入方法依賴的package包/類
/**
 * Instantiates a new Encrypted file data source factory.
 *
 * @param context         the context
 * @param cipher          the cipher
 * @param secretKeySpec   the secret key spec
 * @param ivParameterSpec the iv parameter spec
 * @param listener        the listener
 */
public EncryptedFileDataSourceFactory(Context context, Cipher cipher, SecretKeySpec secretKeySpec, IvParameterSpec ivParameterSpec, TransferListener<? super DataSource> listener) {
    mCipher = cipher;
    mSecretKeySpec = secretKeySpec;
    mIvParameterSpec = ivParameterSpec;
    mTransferListener = listener;
    String userAgent = Util.getUserAgent(context, context.getPackageName());
    this.context = context.getApplicationContext();
    this.baseDataSourceFactory = new DefaultDataSourceFactory(context, userAgent);
}
 
開發者ID:yangchaojiang,項目名稱:yjPlay,代碼行數:19,代碼來源:EncryptedFileDataSourceFactory.java

示例10: b

import android.content.Context; //導入方法依賴的package包/類
private b(Context context) {
    if (context == null) {
        c.a("create db fail, context is null!");
    } else {
        this.a = new a(context.getApplicationContext(), "mwsdk_analytics.db");
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:8,代碼來源:b.java

示例11: init

import android.content.Context; //導入方法依賴的package包/類
public void init(Context context) {
    //獲取係統默認的異常處理器
    mDefaultCrashHandler = Thread.getDefaultUncaughtExceptionHandler();
    //將當前實例設為係統默認的異常處理器
    Thread.setDefaultUncaughtExceptionHandler(this);
    //獲取Context,方便內部使用
    mContext = context.getApplicationContext();
}
 
開發者ID:jianesrq0724,項目名稱:UpdateLibrary,代碼行數:9,代碼來源:CrashHandler.java

示例12: init

import android.content.Context; //導入方法依賴的package包/類
public void init(Context context) {
    mContext = context.getApplicationContext();
    PATH = Environment.getExternalStorageDirectory().getPath()
            + "/"
            + mContext.getResources().getString(R.string.app_name)
            + "/log/";

    mDefaultCrashHandler = Thread.getDefaultUncaughtExceptionHandler();
    Thread.setDefaultUncaughtExceptionHandler(this);
}
 
開發者ID:InnoFang,項目名稱:Android-Code-Demos,代碼行數:11,代碼來源:CrashHandler.java

示例13: CpuMonitor

import android.content.Context; //導入方法依賴的package包/類
public CpuMonitor(Context context) {
    Log.d(TAG, "CpuMonitor ctor.");
    appContext = context.getApplicationContext();
    userCpuUsage = new MovingAverage(MOVING_AVERAGE_SAMPLES);
    systemCpuUsage = new MovingAverage(MOVING_AVERAGE_SAMPLES);
    totalCpuUsage = new MovingAverage(MOVING_AVERAGE_SAMPLES);
    frequencyScale = new MovingAverage(MOVING_AVERAGE_SAMPLES);
    lastStatLogTimeMs = SystemClock.elapsedRealtime();

    scheduleCpuUtilizationTask();
}
 
開發者ID:lgyjg,項目名稱:AndroidRTC,代碼行數:12,代碼來源:CpuMonitor.java

示例14: getInstance

import android.content.Context; //導入方法依賴的package包/類
public synchronized static DeviceManager getInstance(Context context) {
    if (sharedInstance == null) {
        sharedInstance = new DeviceManager(context.getApplicationContext());
    }
    return sharedInstance;
}
 
開發者ID:inovait,項目名稱:neatle,代碼行數:7,代碼來源:DeviceManager.java

示例15: OpenConfig

import android.content.Context; //導入方法依賴的package包/類
private OpenConfig(Context context, String str) {
    this.c = context.getApplicationContext();
    this.d = str;
    a();
    b();
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:7,代碼來源:OpenConfig.java


注:本文中的android.content.Context.getApplicationContext方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。