當前位置: 首頁>>代碼示例>>Java>>正文


Java Activity.getApplication方法代碼示例

本文整理匯總了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);
        }
    }
}
 
開發者ID:petterh,項目名稱:react-native-android-activity,代碼行數:18,代碼來源:ActivityStarterModule.java

示例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));
        }
    }
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:20,代碼來源:BrowserByFolder.java

示例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));
    }
}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:21,代碼來源:BrowserByVideoObjects.java

示例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;
}
 
開發者ID:Bodo1981,項目名稱:conductor-dagger,代碼行數:22,代碼來源:ConductorInjection.java

示例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();
        }
    }
}
 
開發者ID:brevent,項目名稱:Brevent,代碼行數:26,代碼來源:SettingsFragment.java

示例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();
}
 
開發者ID:guodroid,項目名稱:okwallet,代碼行數:9,代碼來源:BackupWalletDialogFragment.java

示例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();
}
 
開發者ID:guodroid,項目名稱:okwallet,代碼行數:9,代碼來源:AlertDialogsFragment.java

示例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();
}
 
開發者ID:guodroid,項目名稱:okwallet,代碼行數:8,代碼來源:DiagnosticsFragment.java

示例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;
}
 
開發者ID:A-Miracle,項目名稱:QiangHongBao,代碼行數:8,代碼來源:ExplosionFieldView.java

示例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();
}
 
開發者ID:guodroid,項目名稱:okwallet,代碼行數:12,代碼來源:WalletAddressesFragment.java

示例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);
    }
}
 
開發者ID:brevent,項目名稱:Brevent,代碼行數:16,代碼來源:AppsDonateFragment.java

示例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()));
}
 
開發者ID:guodroid,項目名稱:okwallet,代碼行數:15,代碼來源:WalletBalanceFragment.java

示例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();
}
 
開發者ID:guodroid,項目名稱:okwallet,代碼行數:10,代碼來源:EditAddressBookEntryFragment.java

示例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);
}
 
開發者ID:guodroid,項目名稱:okwallet,代碼行數:11,代碼來源:WalletAddressFragment.java

示例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();
}
 
開發者ID:guodroid,項目名稱:okwallet,代碼行數:11,代碼來源:RaiseFeeDialogFragment.java


注:本文中的android.app.Activity.getApplication方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。