本文整理匯總了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();
}