当前位置: 首页>>代码示例>>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;未经允许,请勿转载。