本文整理汇总了Java中android.app.Activity.getApplication方法的典型用法代码示例。如果您正苦于以下问题:Java Activity.getApplication方法的具体用法?Java Activity.getApplication怎么用?Java Activity.getApplication使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.Activity
的用法示例。
在下文中一共展示了Activity.getApplication方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: callJavaScript
import android.app.Activity; //导入方法依赖的package包/类
@ReactMethod
void callJavaScript() {
Activity activity = getCurrentActivity();
if (activity != null) {
MainApplication application = (MainApplication) activity.getApplication();
ReactNativeHost reactNativeHost = application.getReactNativeHost();
ReactInstanceManager reactInstanceManager = reactNativeHost.getReactInstanceManager();
ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
if (reactContext != null) {
CatalystInstance catalystInstance = reactContext.getCatalystInstance();
WritableNativeArray params = new WritableNativeArray();
params.pushString("Hello, JavaScript!");
catalystInstance.callFunction("JavaScriptVisibleToJava", "alert", params);
}
}
}
示例2: setPresenters
import android.app.Activity; //导入方法依赖的package包/类
public static void setPresenters(Activity activity, CommonPresenter.ExtendedClickListener listener, PresenterAdapterInterface adapterInterface, int viewMode){
BrowserByVideoObjects.setPresenters(activity, listener, adapterInterface, viewMode);
CustomApplication application = (CustomApplication) activity.getApplication();
HttpImageManager imageManager = application.getHttpImageManager();
if(viewMode==VideoUtils.VIEW_MODE_LIST) {
adapterInterface.setPresenter(MetaFile2.class, new Metafile2ListPresenter(activity));
}
else if (viewMode == VideoUtils.VIEW_MODE_GRID_SHORT){
adapterInterface.setPresenter(MetaFile2.class, new Metafile2GridPresenter(activity));
}
else if(viewMode==VideoUtils.VIEW_MODE_DETAILS){
adapterInterface.setPresenter(MetaFile2.class, new Metafile2ListPresenter(activity));
}
else {
adapterInterface.setPresenter(MetaFile2.class, new Metafile2GridPresenter(activity));
}
}
示例3: setPresenters
import android.app.Activity; //导入方法依赖的package包/类
public static void setPresenters(Activity activity, CommonPresenter.ExtendedClickListener listener, PresenterAdapterInterface adapterInterface, int viewMode){
CustomApplication application = (CustomApplication) activity.getApplication();
HttpImageManager imageManager = application.getHttpImageManager();
if(viewMode== VideoUtils.VIEW_MODE_LIST) {
adapterInterface.setPresenter(Video.class, new VideoListPresenter(activity, listener,imageManager));
}
else if (viewMode == VideoUtils.VIEW_MODE_GRID_SHORT){
adapterInterface.setPresenter(Video.class, new VideoGridShortPresenter(activity, listener, imageManager));
}
else if(viewMode==VideoUtils.VIEW_MODE_DETAILS){
adapterInterface.setPresenter(NonIndexedVideo.class, new VideoListPresenter(activity, listener,imageManager));
adapterInterface.setPresenter(Video.class, new VideoListPresenter(activity, listener,imageManager));
adapterInterface.setPresenter(Episode.class, new ScrapedVideoDetailedPresenter(activity, listener,imageManager));
adapterInterface.setPresenter(Movie.class, new ScrapedVideoDetailedPresenter(activity, listener,imageManager));
}
else {
adapterInterface.setPresenter(Video.class, new VideoGridPresenter(activity, listener,imageManager));
}
}
示例4: findHasControllerInjector
import android.app.Activity; //导入方法依赖的package包/类
private static HasControllerInjector findHasControllerInjector(Controller controller) {
Controller parentController = controller;
do {
if ((parentController = parentController.getParentController()) == null) {
Activity activity = controller.getActivity();
if (activity instanceof HasControllerInjector) {
return (HasControllerInjector) activity;
}
if (activity.getApplication() instanceof HasControllerInjector) {
return (HasControllerInjector) activity.getApplication();
}
throw new IllegalArgumentException(
String.format("No injector was found for %s", new Object[] { controller.getClass().getCanonicalName() }));
}
} while (!(parentController instanceof HasControllerInjector));
return (HasControllerInjector) parentController;
}
示例5: onResume
import android.app.Activity; //导入方法依赖的package包/类
@Override
public void onResume() {
super.onResume();
getPreferenceScreen().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
onShowDonationChanged();
Preference preference = getPreferenceScreen().findPreference("brevent_about_developer");
if (!SimpleSu.hasSu() && AppsDisabledFragment.isAdbRunning()) {
preference.setSummary(R.string.brevent_about_developer_adb);
} else {
preference.setSummary(null);
}
preference.setOnPreferenceClickListener(this);
if (BuildConfig.RELEASE) {
Activity activity = getActivity();
BreventApplication application = (BreventApplication) activity.getApplication();
double donation = BreventApplication.getDonation(application);
int playDonation = BreventApplication.getPlayDonation(application);
String amount = DecimalUtils.format(donation + playDonation);
if (mAmount == null) {
mAmount = amount;
} else if (!Objects.equals(mAmount, amount)) {
activity.recreate();
}
}
}
示例6: onAttach
import android.app.Activity; //导入方法依赖的package包/类
@Override
public void onAttach(final Activity activity) {
super.onAttach(activity);
this.activity = (AbstractWalletActivity) activity;
this.application = (WalletApplication) activity.getApplication();
this.wallet = application.getWallet();
}
示例7: onAttach
import android.app.Activity; //导入方法依赖的package包/类
@Override
public void onAttach(final Activity activity) {
super.onAttach(activity);
this.activity = activity;
this.application = (WalletApplication) activity.getApplication();
this.packageManager = activity.getPackageManager();
}
示例8: onAttach
import android.app.Activity; //导入方法依赖的package包/类
@Override
public void onAttach(final Activity activity) {
super.onAttach(activity);
this.activity = activity;
this.application = (WalletApplication) activity.getApplication();
}
示例9: attach2Window
import android.app.Activity; //导入方法依赖的package包/类
public static ExplosionFieldView attach2Window(Activity activity) {
ViewGroup rootView = (ViewGroup) activity.findViewById(Window.ID_ANDROID_CONTENT);
ExplosionFieldView explosionField = new ExplosionFieldView(activity.getApplication());
rootView.addView(explosionField, new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
return explosionField;
}
示例10: onAttach
import android.app.Activity; //导入方法依赖的package包/类
@Override
public void onAttach(final Activity activity) {
super.onAttach(activity);
this.activity = (AddressBookActivity) activity;
this.application = (WalletApplication) activity.getApplication();
this.config = application.getConfiguration();
this.wallet = application.getWallet();
this.clipboardManager = (ClipboardManager) activity.getSystemService(Context.CLIPBOARD_SERVICE);
this.contentResolver = activity.getContentResolver();
}
示例11: onShow
import android.app.Activity; //导入方法依赖的package包/类
@Override
public void onShow(DialogInterface dialog) {
Activity activity = getActivity();
if (activity == null) {
return;
}
BreventApplication application = (BreventApplication) activity.getApplication();
if (application.isUnsafe() || application.getPackageManager()
.getLaunchIntentForPackage(DonateActivity.PACKAGE_ALIPAY) == null) {
((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false);
}
if (!BreventActivity.hasEmailClient(application)) {
((AlertDialog) dialog).getButton(AlertDialog.BUTTON_NEGATIVE).setEnabled(false);
}
}
示例12: onAttach
import android.app.Activity; //导入方法依赖的package包/类
@Override
public void onAttach(final Activity activity) {
super.onAttach(activity);
this.activity = (AbstractBindServiceActivity) activity;
this.application = (WalletApplication) activity.getApplication();
this.config = application.getConfiguration();
this.wallet = application.getWallet();
this.loaderManager = getLoaderManager();
showLocalBalance = getResources().getBoolean(R.bool.show_local_balance);
installedFromGooglePlay = "com.android.vending"
.equals(application.getPackageManager().getInstallerPackageName(application.getPackageName()));
}
示例13: onAttach
import android.app.Activity; //导入方法依赖的package包/类
@Override
public void onAttach(final Activity activity) {
super.onAttach(activity);
this.activity = activity;
final WalletApplication application = (WalletApplication) activity.getApplication();
this.wallet = application.getWallet();
this.contentResolver = activity.getContentResolver();
}
示例14: onAttach
import android.app.Activity; //导入方法依赖的package包/类
@Override
public void onAttach(final Activity activity) {
super.onAttach(activity);
this.activity = activity;
this.application = (WalletApplication) activity.getApplication();
this.config = application.getConfiguration();
this.loaderManager = getLoaderManager();
this.nfcAdapter = NfcAdapter.getDefaultAdapter(activity);
}
示例15: onAttach
import android.app.Activity; //导入方法依赖的package包/类
@Override
public void onAttach(final Activity activity) {
super.onAttach(activity);
this.activity = (AbstractWalletActivity) activity;
this.application = (WalletApplication) activity.getApplication();
this.config = application.getConfiguration();
this.wallet = application.getWallet();
this.loaderManager = getLoaderManager();
}