Example usage for android.app Activity getApplication

List of usage examples for android.app Activity getApplication

Introduction

In this page you can find the example usage for android.app Activity getApplication.

Prototype

public final Application getApplication() 

Source Link

Document

Return the application that owns this activity.

Usage

From source file:org.jared.synodroid.ds.action.AddTaskAction.java

public void execute(ResponseHandler handlerP, SynoServer serverP) throws Exception {
    if (use_safe && serverP.getDsmVersion().smallerThen(DSMVersion.VERSION3_1)) {
        //new TorrentDownloadAndAdd((Fragment)handlerP).execute(uri.toString());
        Activity a = ((Fragment) handlerP).getActivity();
        Intent msgIntent = new Intent(a, DownloadIntentService.class);
        msgIntent.putExtra(DownloadIntentService.URL, uri.toString());
        msgIntent.putExtra(DownloadIntentService.DEBUG, ((Synodroid) a.getApplication()).DEBUG);
        a.startService(msgIntent);//from   ww  w. j ava  2  s. co  m
    } else {
        if (task.outside_url) {
            // Start task using url instead of reading file
            serverP.getDSMHandlerFactory().getDSHandler().uploadUrl(uri, null, null);
        } else {
            //serverP.getDSMHandlerFactory().getDSHandler().upload((Fragment) handlerP, uri);
            Activity a = ((Fragment) handlerP).getActivity();
            Intent msgIntent = new Intent(a, UploadIntentService.class);
            msgIntent.putExtra(UploadIntentService.URL, uri.toString());
            if (serverP.getDsmVersion().smallerThen(DSMVersion.VERSION3_1)) {
                msgIntent.putExtra(UploadIntentService.DIRECTORY, "");
            } else {
                msgIntent.putExtra(UploadIntentService.DIRECTORY,
                        serverP.getDSMHandlerFactory().getDSHandler().getSharedDirectory(false));
            }
            msgIntent.putExtra(UploadIntentService.COOKIES, serverP.getCookies());
            msgIntent.putExtra(UploadIntentService.DSM_VERSION, serverP.getDsmVersion().getTitle());
            msgIntent.putExtra(UploadIntentService.PATH, serverP.getUrl());
            msgIntent.putExtra(UploadIntentService.DEBUG, ((Synodroid) a.getApplication()).DEBUG);
            a.startService(msgIntent);
        }
    }
}

From source file:org.jared.synodroid.ds.action.AddPwTaskAction.java

public void execute(ResponseHandler handlerP, SynoServer serverP) throws Exception {
    if (use_safe && serverP.getDsmVersion().smallerThen(DSMVersion.VERSION3_1)) {
        //new TorrentDownloadAndAdd((Fragment)handlerP).execute(uri.toString());
        Activity a = ((Fragment) handlerP).getActivity();
        Intent msgIntent = new Intent(a, DownloadIntentService.class);
        msgIntent.putExtra(DownloadIntentService.URL, uri.toString());
        msgIntent.putExtra(DownloadIntentService.DEBUG, ((Synodroid) a.getApplication()).DEBUG);
        a.startService(msgIntent);/* w  ww . j  ava2  s  . c o  m*/
    } else {
        if (task.outside_url) {
            // Start task using url instead of reading file
            serverP.getDSMHandlerFactory().getDSHandler().uploadUrl(uri, uname, pass);
        } else {
            Activity a = ((Fragment) handlerP).getActivity();
            Intent msgIntent = new Intent(a, UploadIntentService.class);
            msgIntent.putExtra(UploadIntentService.URL, uri.toString());
            if (serverP.getDsmVersion().smallerThen(DSMVersion.VERSION3_1)) {
                msgIntent.putExtra(UploadIntentService.DIRECTORY, "");
            } else {
                msgIntent.putExtra(UploadIntentService.DIRECTORY,
                        serverP.getDSMHandlerFactory().getDSHandler().getSharedDirectory(false));
            }
            msgIntent.putExtra(UploadIntentService.COOKIES, serverP.getCookies());
            msgIntent.putExtra(UploadIntentService.DSM_VERSION, serverP.getDsmVersion().getTitle());
            msgIntent.putExtra(UploadIntentService.PATH, serverP.getUrl());
            msgIntent.putExtra(UploadIntentService.DEBUG, ((Synodroid) a.getApplication()).DEBUG);
            a.startService(msgIntent);
        }
    }
}

From source file:com.feathercoin.wallet.feathercoin.ui.WalletBalanceFragment.java

@Override
public void onAttach(final Activity activity) {
    super.onAttach(activity);

    this.activity = (AbstractWalletActivity) activity;
    this.application = (WalletApplication) activity.getApplication();
    this.wallet = application.getWallet();
    this.prefs = PreferenceManager.getDefaultSharedPreferences(activity);
    this.loaderManager = getLoaderManager();

    showLocalBalance = getResources().getBoolean(R.bool.show_local_balance);
}

From source file:cc.mintcoin.wallet.ui.WalletBalanceFragment.java

@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();

    showLocalBalance = getResources().getBoolean(R.bool.show_local_balance);
}

From source file:com.jefftharris.passwdsafe.PreferencesFragment.java

@Override
public void promptConfirmed(Bundle confirmArgs) {
    ConfirmAction action;// w  ww  .  j a  v a2 s.c  o m
    try {
        action = ConfirmAction.valueOf(confirmArgs.getString(CONFIRM_ARG_ACTION));
    } catch (Exception e) {
        return;
    }

    switch (action) {
    case CLEAR_ALL_NOTIFS: {
        Activity act = getActivity();
        PasswdSafeApp app = (PasswdSafeApp) act.getApplication();
        app.getNotifyMgr().handleClearAllConfirmed();
        break;
    }
    case CLEAR_ALL_SAVED: {
        SavedPasswordsMgr passwdMgr = new SavedPasswordsMgr(getContext());
        passwdMgr.removeAllSavedPasswords();
        break;
    }
    }
}

From source file:com.kncwallet.wallet.ui.ExchangeRatesFragment.java

@Override
public void onAttach(final Activity activity) {
    super.onAttach(activity);

    this.activity = (AbstractWalletActivity) activity;
    this.application = (WalletApplication) activity.getApplication();
    this.wallet = application.getWallet();
    this.prefs = PreferenceManager.getDefaultSharedPreferences(activity);
    this.loaderManager = getLoaderManager();
}

From source file:de.schildbach.wallet.ui.BackupWalletDialogFragment.java

@Override
public void onAttach(final Activity activity) {
    super.onAttach(activity);

    this.activity = (AbstractWalletActivity) activity;
    this.application = (WalletApplication) activity.getApplication();
    this.wallet = application.getWallet();
}

From source file:com.jefftharris.passwdsafe.PreferencesFragment.java

@Override
public boolean onPreferenceClick(Preference preference) {
    switch (preference.getKey()) {
    case Preferences.PREF_DEF_FILE: {
        Intent intent = new Intent(Intent.ACTION_CREATE_SHORTCUT, null, getContext(),
                LauncherFileShortcuts.class);
        intent.putExtra(LauncherFileShortcuts.EXTRA_IS_DEFAULT_FILE, true);
        startActivityForResult(intent, REQUEST_DEFAULT_FILE);
        return true;
    }/* w  w w .  ja v  a2s  .  c o m*/
    case Preferences.PREF_PASSWD_CLEAR_ALL_NOTIFS: {
        Activity act = getActivity();
        PasswdSafeApp app = (PasswdSafeApp) act.getApplication();
        Bundle confirmArgs = new Bundle();
        confirmArgs.putString(CONFIRM_ARG_ACTION, ConfirmAction.CLEAR_ALL_NOTIFS.name());
        DialogFragment dlg = app.getNotifyMgr().createClearAllPrompt(act, confirmArgs);
        dlg.setTargetFragment(this, REQUEST_CLEAR_ALL_NOTIFS);
        dlg.show(getFragmentManager(), "clearNotifsConfirm");
        return true;
    }
    case Preferences.PREF_PASSWD_CLEAR_ALL_SAVED: {
        Bundle confirmArgs = new Bundle();
        confirmArgs.putString(CONFIRM_ARG_ACTION, ConfirmAction.CLEAR_ALL_SAVED.name());
        ConfirmPromptDialog dlg = ConfirmPromptDialog.newInstance(getString(R.string.clear_all_saved_passwords),
                getString(R.string.erase_all_saved_passwords), getString(R.string.clear), confirmArgs);
        dlg.setTargetFragment(this, REQUEST_CLEAR_ALL_SAVED);
        dlg.show(getFragmentManager(), "clearSavedConfirm");
        return true;
    }
    }
    return false;
}

From source file:de.schildbach.wallet.ui.RestoreWalletFromSeedDialogFragment.java

@Override
public void onAttach(final Activity activity) {
    super.onAttach(activity);

    this.activity = (WalletActivity) activity;
    WalletApplication application = (WalletApplication) activity.getApplication();
    this.wallet = application.getWallet();
}

From source file:cc.mintcoin.wallet.ui.ExchangeRatesFragment.java

@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();
}