本文整理汇总了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;
}
示例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");
}
}
示例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
}
示例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();
}
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
}
示例11: FakeR
import android.app.Activity; //导入方法依赖的package包/类
public FakeR(Activity activity) {
context = activity.getApplicationContext();
packageName = context.getPackageName();
}
示例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;
}
示例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();
}
示例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);
}
示例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);
}