Example usage for android.app Activity getBaseContext

List of usage examples for android.app Activity getBaseContext

Introduction

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

Prototype

public Context getBaseContext() 

Source Link

Usage

From source file:com.yutong.axxc.parents.view.common.ActivityUtils.java

/**
 * activity//from w w  w  .  j  a  va  2 s . c  o  m
 * @param from ?activity
 * @param to activity
 * @param extras ??
 */
public static void changeActivity(Activity from, Class<?> to, Bundle extras) {
    // Intent intent = setIntent(from, to, extras);
    Intent intent = new Intent();
    if (extras != null)
        intent.putExtras(extras);
    intent.setClass(from.getBaseContext(), to);
    intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
    from.startActivity(intent);
    //from.overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
    from.overridePendingTransition(R.anim.enter_righttoleft, R.anim.exit_righttoleft);
}

From source file:com.sunhz.projectutils.base.BaseFragment.java

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

    mContext = activity.getBaseContext();
    mApplicationContext = mContext.getApplicationContext();
    mActivity = activity;//from  w  ww  .  j a  v a2s .c o  m

    this.volleyQueue = Volley.newRequestQueue(mContext);
    this.policy = new DefaultRetryPolicy(Constant.TimeInApplication.NET_TIMEOUT,
            DefaultRetryPolicy.DEFAULT_MAX_RETRIES, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT);
}

From source file:org.totschnig.myexpenses.dialog.DialogUtils.java

/**
 * @return Dialog to be used from Preference,
 * and from version update//from   w w w .  j a v  a  2 s . c  o  m
 */
public static Dialog sendWithFTPDialog(final Activity ctx) {
    return new AlertDialog.Builder(ctx).setMessage(R.string.no_app_handling_ftp_available)
            .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    ctx.dismissDialog(R.id.FTP_DIALOG);
                    Intent intent = new Intent(Intent.ACTION_VIEW);
                    intent.setData(Uri.parse(MyApplication.getMarketPrefix() + "org.totschnig.sendwithftp"));
                    if (Utils.isIntentAvailable(ctx, intent)) {
                        ctx.startActivity(intent);
                    } else {
                        Toast.makeText(ctx.getBaseContext(), R.string.error_accessing_market, Toast.LENGTH_LONG)
                                .show();
                    }
                }
            }).setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    ctx.dismissDialog(R.id.FTP_DIALOG);
                }
            }).create();
}

From source file:com.ap.github.base.BaseFragment.java

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

    mContext = activity.getBaseContext();
    mApplicationContext = activity.getApplicationContext();
    mActivity = activity;//from   w  ww. j a  v  a2  s  .c  om
}

From source file:com.SecUpwN.AIMSICD.fragments.AboutFragment.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    mContext = activity.getBaseContext();
}

From source file:com.ui.UiActivity.java

public void startActivity(Activity activity, Class<?> zls, final Map<String, String> intentParameter) {
    Intent intent = (Intent) activity.getIntent();
    intent.setClass(activity.getBaseContext(), zls);
    if (null != intentParameter) {
        for (Map.Entry<String, String> entry : intentParameter.entrySet()) {
            intent.putExtra(entry.getKey(), entry.getValue());
        }/* w  w w.  ja va 2  s .  co  m*/
    }
    activity.startActivity(intent);
    activity.finish();
}

From source file:be.evias.cloudLogin.cloudLoginPageFragment.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    ((cloudLoginMainActivity) activity).onSectionAttached(getArguments().getInt(ARG_SECTION_NUMBER));

    mContext = activity.getBaseContext();
    mPrefs = activity.getBaseContext().getSharedPreferences("cloudlogin", Context.MODE_PRIVATE);
}

From source file:com.granita.tasks.SettingsListFragment.java

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    mContext = activity.getBaseContext();
    mAutority = getActivity().getString(R.string.org_dmfs_tasks_authority);
}

From source file:it.geosolutions.geocollect.android.map.GeoCollectMapActivity.java

/**
 * Display a confirm prompt before logging out the user
 *//*from   w  ww .  ja  va  2  s  .  co  m*/
public static void confirmLogout(final Activity act) {
    final Context ctx = act.getBaseContext();
    new AlertDialog.Builder(act).setTitle(R.string.action_logout).setMessage(R.string.button_confirm_logout)
            .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {

                    //clear user data
                    final Editor ed = PreferenceManager.getDefaultSharedPreferences(ctx).edit();

                    ed.putString(LoginActivity.PREFS_USER_EMAIL, null);
                    ed.putString(LoginActivity.PREFS_USER_FORENAME, null);
                    ed.putString(LoginActivity.PREFS_USER_SURNAME, null);
                    ed.putString(LoginActivity.PREFS_PASSWORD, null);
                    ed.putString(LoginActivity.PREFS_AUTH_KEY, null);
                    ed.putString(LoginActivity.PREFS_USER_ENTE, null);

                    ed.commit();

                    Toast.makeText(ctx, ctx.getString(R.string.logout_logged_out), Toast.LENGTH_LONG).show();

                    if (act != null) {
                        act.startActivityForResult(new Intent(ctx, LoginActivity.class),
                                LoginActivity.REQUEST_LOGIN);
                    }

                }
            }).setNegativeButton(android.R.string.no, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    // do nothing
                }
            }).show();
}

From source file:at.ac.tuwien.caa.docscan.logic.DataLog.java

public void shareLog(Activity activity) {

    File logPath = new File(activity.getBaseContext().getFilesDir(), LOG_FILE_NAME);
    Uri contentUri = FileProvider.getUriForFile(activity.getBaseContext(), "at.ac.tuwien.caa.fileprovider",
            logPath);/*from  ww w. ja  v  a2 s .  c o m*/

    String emailSubject = activity.getBaseContext().getString(R.string.log_email_subject);
    String[] emailTo = new String[] { activity.getBaseContext().getString(R.string.log_email_to) };
    String text = activity.getBaseContext().getString(R.string.log_email_text);

    Intent intent = ShareCompat.IntentBuilder.from(activity).setType("text/plain").setSubject(emailSubject)
            .setEmailTo(emailTo).setStream(contentUri).setText(text).getIntent()
            .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);

    activity.startActivity(intent);

}