当前位置: 首页>>代码示例>>Java>>正文


Java Activity.getApplicationContext方法代码示例

本文整理汇总了Java中android.app.Activity.getApplicationContext方法的典型用法代码示例。如果您正苦于以下问题:Java Activity.getApplicationContext方法的具体用法?Java Activity.getApplicationContext怎么用?Java Activity.getApplicationContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.app.Activity的用法示例。


在下文中一共展示了Activity.getApplicationContext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAvailableFileSystems

import android.app.Activity; //导入方法依赖的package包/类
protected HashMap<String, String> getAvailableFileSystems(Activity activity) {
    Context context = activity.getApplicationContext();
    HashMap<String, String> availableFileSystems = new HashMap<String,String>();

    availableFileSystems.put("files", context.getFilesDir().getAbsolutePath());
    availableFileSystems.put("documents", new File(context.getFilesDir(), "Documents").getAbsolutePath());
    availableFileSystems.put("cache", context.getCacheDir().getAbsolutePath());
    availableFileSystems.put("root", "/");
    if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
      try {
        availableFileSystems.put("files-external", context.getExternalFilesDir(null).getAbsolutePath());
        availableFileSystems.put("sdcard", Environment.getExternalStorageDirectory().getAbsolutePath());
        availableFileSystems.put("cache-external", context.getExternalCacheDir().getAbsolutePath());
      }
      catch(NullPointerException e) {
          LOG.d(LOG_TAG, "External storage unavailable, check to see if USB Mass Storage Mode is on");
      }
    }

    return availableFileSystems;
}
 
开发者ID:rodrigonsh,项目名称:alerta-fraude,代码行数:22,代码来源:FileUtils.java

示例2: onAttach

import android.app.Activity; //导入方法依赖的package包/类
@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);

    mContext = activity.getApplicationContext();

    try {
        mFragmentListener = (MessageViewFragmentListener) activity;
    } catch (ClassCastException e) {
        throw new ClassCastException(activity.getClass() +
                " must implement MessageViewFragmentListener");
    }
}
 
开发者ID:philipwhiuk,项目名称:q-mail,代码行数:14,代码来源:MessageViewFragment.java

示例3: createToast

import android.app.Activity; //导入方法依赖的package包/类
@NonNull
private void createToast(Activity activity, View layout) {
    //Creating the Toast object
    toast = new Toast(activity.getApplicationContext());
    toast.setDuration(Toast.LENGTH_SHORT);
    toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
    toast.setView(layout);//setting the view of custom toast layout

}
 
开发者ID:kflauri2312lffds,项目名称:Android_watch_magpie,代码行数:10,代码来源:CustomToast.java

示例4: onAttach

import android.app.Activity; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
@Override
public void onAttach(final Activity activity) {
    super.onAttach(activity);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
        this.mContext = activity.getApplicationContext();
    }
}
 
开发者ID:brandall76,项目名称:Saiy-PS,代码行数:9,代码来源:FragmentCustomisation.java

示例5: onStart

import android.app.Activity; //导入方法依赖的package包/类
/** Call this method from your Activity's onStart(). */
public void onStart(Activity act) {
    mActivity = act;
    mAppContext = act.getApplicationContext();

    debugLog("onStart");
    assertConfigured("onStart");

    if (mConnectOnStart) {
        if (mGoogleApiClient.isConnected()) {
            Log.w(TAG,
                    "GameHelper: client was already connected on onStart()");
        } else {
            debugLog("Connecting client.");
            mConnecting = true;
            mGoogleApiClient.connect();
        }
    } else {
        debugLog("Not attempting to connect because mConnectOnStart=false");
        debugLog("Instead, reporting a sign-in failure.");
        mHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                notifyListener(false);
            }
        }, 1000);
    }
}
 
开发者ID:ZephyrVentum,项目名称:FlappySpinner,代码行数:29,代码来源:GameHelper.java

示例6: j

import android.app.Activity; //导入方法依赖的package包/类
public j(Activity activity, SocializeEntity socializeEntity, SHARE_MEDIA share_media,
         UMAuthListener uMAuthListener) {
    super(activity, ResContainer.getResourceId(activity.getApplicationContext(), ResType
            .STYLE, "umeng_socialize_popup_dialog"));
    this.k = activity.getApplicationContext();
    this.l = activity;
    this.c = uMAuthListener;
    this.m = share_media;
    this.i = UMServiceFactory.getUMSocialService(socializeEntity.mDescriptor);
    SocializeConfig config = this.i.getConfig();
    this.n = config.getFollowFids(share_media);
    this.o = config.getOauthDialogFollowListener();
    switch (s.a[share_media.ordinal()]) {
        case 1:
            this.j = p;
            break;
        case 2:
            this.j = q;
            break;
        case 3:
            this.j = r;
            break;
        case 4:
            this.j = s;
            break;
    }
    LayoutInflater layoutInflater = (LayoutInflater) this.l.getSystemService("layout_inflater");
    int resourceId = ResContainer.getResourceId(this.k, ResType.LAYOUT,
            "umeng_socialize_oauth_dialog");
    int resourceId2 = ResContainer.getResourceId(this.k, ResType.ID, "umeng_socialize_follow");
    int resourceId3 = ResContainer.getResourceId(this.k, ResType.ID,
            "umeng_socialize_follow_check");
    this.d = layoutInflater.inflate(resourceId, null);
    View findViewById = this.d.findViewById(resourceId2);
    this.f = (CheckBox) this.d.findViewById(resourceId3);
    Object obj = (this.n == null || this.n.size() <= 0) ? null : 1;
    Object obj2 = (share_media == SHARE_MEDIA.SINA || share_media == SHARE_MEDIA.TENCENT) ? 1
            : null;
    if (obj == null || obj2 == null) {
        findViewById.setVisibility(8);
    } else {
        findViewById.setVisibility(0);
    }
    int resourceId4 = ResContainer.getResourceId(this.k, ResType.ID, "progress_bar_parent");
    resourceId = ResContainer.getResourceId(this.k, ResType.ID,
            "umeng_socialize_title_bar_leftBt");
    resourceId2 = ResContainer.getResourceId(this.k, ResType.ID,
            "umeng_socialize_title_bar_rightBt");
    resourceId3 = ResContainer.getResourceId(this.k, ResType.ID,
            "umeng_socialize_title_bar_middleTv");
    int resourceId5 = ResContainer.getResourceId(this.k, ResType.ID,
            "umeng_socialize_titlebar");
    this.e = this.d.findViewById(resourceId4);
    this.e.setVisibility(0);
    ((Button) this.d.findViewById(resourceId)).setOnClickListener(new l(this));
    this.d.findViewById(resourceId2).setVisibility(8);
    ((TextView) this.d.findViewById(resourceId3)).setText("授权" + SocialSNSHelper.getShowWord
            (this.k, share_media));
    b();
    View mVar = new m(this, this.k, findViewById, this.d.findViewById(resourceId5),
            SocializeUtils.dip2Px(this.k, 200.0f));
    mVar.addView(this.d, -1, -1);
    setContentView(mVar);
    LayoutParams attributes = getWindow().getAttributes();
    if (SocializeUtils.isFloatWindowStyle(this.k)) {
        int[] floatWindowSize = SocializeUtils.getFloatWindowSize(this.k);
        attributes.width = floatWindowSize[0];
        attributes.height = floatWindowSize[1];
        resourceId4 = ResContainer.getResourceId(getContext(), ResType.STYLE,
                "umeng_socialize_dialog_anim_fade");
    } else {
        attributes.height = -1;
        attributes.width = -1;
        resourceId4 = ResContainer.getResourceId(getContext(), ResType.STYLE,
                "umeng_socialize_dialog_animations");
    }
    attributes.gravity = 17;
    getWindow().getAttributes().windowAnimations = resourceId4;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:80,代码来源:j.java

示例7: startActivity

import android.app.Activity; //导入方法依赖的package包/类
public static void startActivity(Activity activity, Class targetActivity, int requestCode, Bundle data) {
    Intent intent = new Intent(activity.getApplicationContext(), targetActivity);
    if (data != null) {
        intent.putExtras(data);
    }
    if (requestCode != -1) {
        activity.startActivityForResult(intent, requestCode);
    } else {
        activity.startActivity(intent);
    }
}
 
开发者ID:harrylefit,项目名称:EazyBaseMVP,代码行数:12,代码来源:ActivityUtils.java

示例8: fireIntent

import android.app.Activity; //导入方法依赖的package包/类
private static void fireIntent(Activity activity, Intent intent) {
    if (sFakeIntentReceiverForTesting != null) {
        Context context = activity.getApplicationContext();
        sFakeIntentReceiverForTesting.fireIntent(context, intent);
    } else {
        activity.startActivity(intent);
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:9,代码来源:ShareHelper.java

示例9: takeScreenShot

import android.app.Activity; //导入方法依赖的package包/类
private static Bitmap takeScreenShot(Activity activity) {

        Context ctx = activity.getApplicationContext();
        String screenShotDir = getWeexScreenShotDir(ctx);

        View view = activity.getWindow().getDecorView();

        rootView = view;
        firstScrollView = findFirstScrollerByRootView(rootView);
        firstListView = findFirstListByRootView(rootView);

        Bitmap snapBitmap = null;
        // 优先scroller ->list->root
        if(null !=firstScrollView ){
            snapBitmap = doSanpForListOrScroller(firstScrollView);
        }
        else {
            Log.e("weex_test", "firstScrollView is " + firstScrollView);
            if (null != firstListView){
                snapBitmap = doSanpForListOrScroller(firstListView);
            }else {
                Log.e("weex_test", "firstListView is " + firstListView);

                if(null != rootView){
//                    snapBitmap = doSanpForListOrScroller(rootView);
                }
            }
        }

        return  snapBitmap;

    }
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:33,代码来源:ScreenShot.java

示例10: onStart

import android.app.Activity; //导入方法依赖的package包/类
/**
 * Call this method from your Activity's onStart().
 */
public void onStart(Activity act) {
    mActivity = act;
    mAppContext = act.getApplicationContext();

    debugLog("onStart");
    assertConfigured("onStart");

    if (mConnectOnStart) {
        if (mGoogleApiClient.isConnected()) {
            Log.w(TAG,
                    "GameHelper: client was already connected on onStart()");
        } else {
            debugLog("Connecting client.");
            mConnecting = true;
            mGoogleApiClient.connect();
        }
    } else {
        debugLog("Not attempting to connect because mConnectOnStart=false");
        debugLog("Instead, reporting a sign-in failure.");
        mHandler.postDelayed(new Runnable() {
            @Override
            public void run() {
                notifyListener(false);
            }
        }, 1000);
    }
}
 
开发者ID:jaysondc,项目名称:TripleTap,代码行数:31,代码来源:GameHelper.java

示例11: FakeR

import android.app.Activity; //导入方法依赖的package包/类
public FakeR(Activity activity) {
	context = activity.getApplicationContext();
	packageName = context.getPackageName();
}
 
开发者ID:abelabbesnabi,项目名称:cordova-plugin-image-picker,代码行数:5,代码来源:FakeR.java

示例12: getAssitIntent

import android.app.Activity; //导入方法依赖的package包/类
private Intent getAssitIntent(Activity activity) {
    Intent intent = new Intent(activity.getApplicationContext(), AssistActivity.class);
    intent.putExtra(SystemUtils.IS_LOGIN, true);
    return intent;
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:6,代码来源:BaseApi.java

示例13: GameHelper

import android.app.Activity; //导入方法依赖的package包/类
/**
 * Construct a GameHelper object, initially tied to the given Activity.
 * After constructing this object, call @link{setup} from the onCreate()
 * method of your Activity.
 *
 * @param clientsToUse
 *            the API clients to use (a combination of the CLIENT_* flags,
 *            or CLIENT_ALL to mean all clients).
 */
public GameHelper(Activity activity, int clientsToUse) {
    mActivity = activity;
    mAppContext = activity.getApplicationContext();
    mRequestedClients = clientsToUse;
    mHandler = new Handler();
}
 
开发者ID:justinmarentette11,项目名称:Tower-Defense-Galaxy,代码行数:16,代码来源:GameHelper.java

示例14: startActivity

import android.app.Activity; //导入方法依赖的package包/类
/**
 * 跳转界面
 *
 * @param activity
 * @param homeActivityClass
 */
public static void startActivity(Activity activity, Class homeActivityClass) {
    Intent intent = new Intent(activity.getApplicationContext(), homeActivityClass);
    activity.startActivity(intent);
}
 
开发者ID:hshare,项目名称:MVPArmsTest1,代码行数:11,代码来源:UiUtils.java

示例15: startActivity

import android.app.Activity; //导入方法依赖的package包/类
/**
 * 跳转界面 3
 *
 * @param activity
 * @param homeActivityClass
 */
public static void startActivity(Activity activity, Class homeActivityClass) {
    Intent intent = new Intent(activity.getApplicationContext(), homeActivityClass);
    activity.startActivity(intent);
}
 
开发者ID:xiaobailong24,项目名称:MVVMArms,代码行数:11,代码来源:UiUtils.java


注:本文中的android.app.Activity.getApplicationContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。