本文整理了Java中android.support.v4.app.FragmentActivity.getApplicationContext()
方法的一些代码示例,展示了FragmentActivity.getApplicationContext()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FragmentActivity.getApplicationContext()
方法的具体详情如下:
包路径:android.support.v4.app.FragmentActivity
类名称:FragmentActivity
方法名:getApplicationContext
暂无
代码示例来源:origin: smuyyh/BookReader
public Context getApplicationContext() {
return this.activity == null ? (getActivity() == null ? null : getActivity()
.getApplicationContext()) : this.activity.getApplicationContext();
}
代码示例来源:origin: HotBitmapGG/bilibili-android-client
public Context getApplicationContext() {
return this.activity == null ? (getActivity() == null ?
null : getActivity().getApplicationContext()) : this.activity.getApplicationContext();
}
代码示例来源:origin: k9mail/k-9
private void showUnableToDecodeError() {
Context context = getActivity().getApplicationContext();
Toast.makeText(context, R.string.message_view_toast_unable_to_display_message, Toast.LENGTH_SHORT).show();
}
代码示例来源:origin: commonsguy/cw-omnibus
LoadCursorTask() {
this.ctxt=getActivity().getApplicationContext();
}
代码示例来源:origin: bumptech/glide
@NonNull
public RequestManager get(@NonNull FragmentActivity activity) {
if (Util.isOnBackgroundThread()) {
return get(activity.getApplicationContext());
} else {
assertNotDestroyed(activity);
FragmentManager fm = activity.getSupportFragmentManager();
return supportFragmentGet(
activity, fm, /*parentHint=*/ null, isActivityVisible(activity));
}
}
代码示例来源:origin: iammert/MaterialIntroView
private void initializeRecyclerview() {
RecyclerView.LayoutManager layoutManager = new GridLayoutManager(getActivity(), 2);
recyclerView.setLayoutManager(layoutManager);
recyclerView.setHasFixedSize(true);
adapter = new RecyclerViewAdapter(getActivity().getApplicationContext());
recyclerView.setAdapter(adapter);
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRetainInstance(true);
rxBluetooth=new RxBluetooth(getActivity().getApplicationContext());
}
代码示例来源:origin: WVector/AppUpdate
/**
* 开启后台服务下载
*/
private void downloadApp() {
//使用ApplicationContext延长他的生命周期
DownloadService.bindService(getActivity().getApplicationContext(), conn);
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRetainInstance(true);
appContext=(Application)getActivity().getApplicationContext();
appContext.bindService(new Intent(getActivity(),
DownloadService.class),
this, Context.BIND_AUTO_CREATE);
}
代码示例来源:origin: iammert/MaterialIntroView
@Override
public void onClick(View v) {
int id = v.getId();
if(id == R.id.button_reset_all)
new PreferencesManager(getActivity().getApplicationContext()).resetAll();
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
rv=view.findViewById(R.id.devices);
rv.setLayoutManager(new LinearLayoutManager(getActivity()));
rv.addItemDecoration(new DividerItemDecoration(getActivity(),
LinearLayoutManager.VERTICAL));
rv.setAdapter(adapter);
rxBluetooth=new RxBluetooth(getActivity().getApplicationContext());
if (!rxBluetooth.isBluetoothAvailable()) {
Toast.makeText(getActivity(), R.string.msg_no_bt, Toast.LENGTH_LONG).show();
}
else {
enableBluetooth(false);
}
}
代码示例来源:origin: Ramotion/paper-onboarding-android
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.onboarding_main_layout, container, false);
// create engine for onboarding element
PaperOnboardingEngine mPaperOnboardingEngine = new PaperOnboardingEngine(view.findViewById(R.id.onboardingRootView), mElements, getActivity().getApplicationContext());
// set listeners
mPaperOnboardingEngine.setOnChangeListener(mOnChangeListener);
mPaperOnboardingEngine.setOnLeftOutListener(mOnLeftOutListener);
mPaperOnboardingEngine.setOnRightOutListener(mOnRightOutListener);
return view;
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRetainInstance(true);
appContext=(Application)getActivity().getApplicationContext();
Intent implicit=new Intent(IDownload.class.getName());
List<ResolveInfo> matches=getActivity().getPackageManager()
.queryIntentServices(implicit, 0);
if (matches.size() == 0) {
Toast.makeText(getActivity(), "Cannot find a matching service!",
Toast.LENGTH_LONG).show();
}
else if (matches.size() > 1) {
Toast.makeText(getActivity(), "Found multiple matching services!",
Toast.LENGTH_LONG).show();
}
else {
Intent explicit=new Intent(implicit);
ServiceInfo svcInfo=matches.get(0).serviceInfo;
ComponentName cn=new ComponentName(svcInfo.applicationInfo.packageName,
svcInfo.name);
explicit.setComponent(cn);
appContext.bindService(explicit, this, Context.BIND_AUTO_CREATE);
}
}
代码示例来源:origin: commonsguy/cw-omnibus
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setRetainInstance(true);
appContext=(Application)getActivity().getApplicationContext();
Intent implicit=new Intent(IDownload.class.getName());
List<ResolveInfo> matches=getActivity().getPackageManager()
.queryIntentServices(implicit, 0);
if (matches.size() == 0) {
Toast.makeText(getActivity(), "Cannot find a matching service!",
Toast.LENGTH_LONG).show();
}
else if (matches.size() > 1) {
Toast.makeText(getActivity(), "Found multiple matching services!",
Toast.LENGTH_LONG).show();
}
else {
Intent explicit=new Intent(implicit);
ServiceInfo svcInfo=matches.get(0).serviceInfo;
ComponentName cn=new ComponentName(svcInfo.applicationInfo.packageName,
svcInfo.name);
explicit.setComponent(cn);
appContext.bindService(explicit, this, Context.BIND_AUTO_CREATE);
}
}
代码示例来源:origin: bumptech/glide
@NonNull
public RequestManager get(@NonNull Fragment fragment) {
Preconditions.checkNotNull(fragment.getActivity(),
"You cannot start a load on a fragment before it is attached or after it is destroyed");
if (Util.isOnBackgroundThread()) {
return get(fragment.getActivity().getApplicationContext());
} else {
FragmentManager fm = fragment.getChildFragmentManager();
return supportFragmentGet(fragment.getActivity(), fm, fragment, fragment.isVisible());
}
}
代码示例来源:origin: arimorty/floatingsearchview
@Override
public void onActionMenuItemSelected(MenuItem item) {
if (item.getItemId() == R.id.action_change_colors) {
mIsDarkSearchTheme = true;
//demonstrate setting colors for items
mSearchView.setBackgroundColor(Color.parseColor("#787878"));
mSearchView.setViewTextColor(Color.parseColor("#e9e9e9"));
mSearchView.setHintTextColor(Color.parseColor("#e9e9e9"));
mSearchView.setActionMenuOverflowColor(Color.parseColor("#e9e9e9"));
mSearchView.setMenuItemIconColor(Color.parseColor("#e9e9e9"));
mSearchView.setLeftActionIconColor(Color.parseColor("#e9e9e9"));
mSearchView.setClearBtnColor(Color.parseColor("#e9e9e9"));
mSearchView.setDividerColor(Color.parseColor("#BEBEBE"));
mSearchView.setLeftActionIconColor(Color.parseColor("#e9e9e9"));
} else {
//just print action
Toast.makeText(getActivity().getApplicationContext(), item.getTitle(),
Toast.LENGTH_SHORT).show();
}
}
});
代码示例来源:origin: arimorty/floatingsearchview
@Override
public void onActionMenuItemSelected(MenuItem item) {
if (item.getItemId() == R.id.action_change_colors) {
mIsDarkSearchTheme = true;
//demonstrate setting colors for items
mSearchView.setBackgroundColor(Color.parseColor("#787878"));
mSearchView.setViewTextColor(Color.parseColor("#e9e9e9"));
mSearchView.setHintTextColor(Color.parseColor("#e9e9e9"));
mSearchView.setActionMenuOverflowColor(Color.parseColor("#e9e9e9"));
mSearchView.setMenuItemIconColor(Color.parseColor("#e9e9e9"));
mSearchView.setLeftActionIconColor(Color.parseColor("#e9e9e9"));
mSearchView.setClearBtnColor(Color.parseColor("#e9e9e9"));
mSearchView.setDividerColor(Color.parseColor("#BEBEBE"));
mSearchView.setLeftActionIconColor(Color.parseColor("#e9e9e9"));
} else {
//just print action
Toast.makeText(getActivity().getApplicationContext(), item.getTitle(),
Toast.LENGTH_SHORT).show();
}
}
});
代码示例来源:origin: arimorty/floatingsearchview
@Override
public void onActionMenuItemSelected(MenuItem item) {
if (item.getItemId() == R.id.action_change_colors) {
mIsDarkSearchTheme = true;
//demonstrate setting colors for items
mSearchView.setBackgroundColor(Color.parseColor("#787878"));
mSearchView.setViewTextColor(Color.parseColor("#e9e9e9"));
mSearchView.setHintTextColor(Color.parseColor("#e9e9e9"));
mSearchView.setActionMenuOverflowColor(Color.parseColor("#e9e9e9"));
mSearchView.setMenuItemIconColor(Color.parseColor("#e9e9e9"));
mSearchView.setLeftActionIconColor(Color.parseColor("#e9e9e9"));
mSearchView.setClearBtnColor(Color.parseColor("#e9e9e9"));
mSearchView.setDividerColor(Color.parseColor("#BEBEBE"));
mSearchView.setLeftActionIconColor(Color.parseColor("#e9e9e9"));
} else {
//just print action
Toast.makeText(getActivity().getApplicationContext(), item.getTitle(),
Toast.LENGTH_SHORT).show();
}
}
});
代码示例来源:origin: k9mail/k-9
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// This fragments adds options to the action bar
setHasOptionsMenu(true);
Context context = getActivity().getApplicationContext();
mController = MessagingController.getInstance(context);
downloadManager = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
messageCryptoPresenter = new MessageCryptoPresenter(messageCryptoMvpView);
messageLoaderHelper = new MessageLoaderHelper(
context, getLoaderManager(), getFragmentManager(), messageLoaderCallbacks);
mInitialized = true;
}
代码示例来源:origin: k9mail/k-9
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Context appContext = getActivity().getApplicationContext();
preferences = Preferences.getPreferences(appContext);
messagingController = MessagingController.getInstance(getActivity().getApplication());
previewLines = K9.messageListPreviewLines();
checkboxes = K9.messageListCheckboxes();
stars = K9.messageListStars();
if (K9.showContactPicture()) {
contactsPictureLoader = ContactPicture.getContactPictureLoader();
}
restoreInstanceState(savedInstanceState);
decodeArguments();
createCacheBroadcastReceiver(appContext);
initialized = true;
}
内容来源于网络,如有侵权,请联系作者删除!