Example usage for android.app Activity startActivity

List of usage examples for android.app Activity startActivity

Introduction

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

Prototype

@Override
public void startActivity(Intent intent) 

Source Link

Document

Same as #startActivity(Intent,Bundle) with no options specified.

Usage

From source file:com.frostwire.android.gui.activities.internal.NavigationMenu.java

private AdMenuItemView initAdMenuItemListener(final Activity activity) {
    AdMenuItemView adMenuItemView = activity.findViewById(R.id.slidermenu_ad_menuitem);
    RelativeLayout menuAd = activity.findViewById(R.id.view_ad_menu_item_ad);
    menuAd.setOnClickListener(v -> {/*from w  w  w  . ja v a 2  s. co m*/
        Intent intent = new Intent(activity, BuyActivity.class);
        activity.startActivity(intent);
    });
    return adMenuItemView;
}

From source file:com.android.tv.settings.dialog.old.BaseDialogFragment.java

public void onActionClicked(Activity activity, Action action) {
    if (activity instanceof ActionAdapter.Listener) {
        ((ActionAdapter.Listener) activity).onActionClicked(action);
    } else {//from www  .  j  a  va 2  s .com
        Intent intent = action.getIntent();
        if (intent != null) {
            activity.startActivity(intent);
            activity.finish();
        }
    }
}

From source file:codepath.watsiapp.utils.Util.java

private static void startShareIntentWithExplicitSocialActivity(Activity ctx, ShareableItem patient,
        Set<String> socialActivitiesName, String displayName) {
    Intent shareIntent = new Intent();
    shareIntent.setAction(Intent.ACTION_SEND);
    shareIntent.setType("text/plain");
    shareIntent.putExtra(Intent.EXTRA_TEXT, patient.getShareableUrl());

    try {//  ww w . j  ava  2  s.c  o m
        final PackageManager pm = ctx.getPackageManager();
        final List activityList = pm.queryIntentActivities(shareIntent, 0);
        int len = activityList.size();
        for (int i = 0; i < len; i++) {
            final ResolveInfo app = (ResolveInfo) activityList.get(i);
            Log.d("#####################", app.activityInfo.name);
            if (socialActivitiesName.contains(app.activityInfo.name)) {
                final ActivityInfo activity = app.activityInfo;
                final ComponentName name = new ComponentName(activity.applicationInfo.packageName,
                        activity.name);
                shareIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
                shareIntent.putExtra(Intent.EXTRA_SUBJECT, "Fund Treatment");
                shareIntent.addCategory(Intent.CATEGORY_LAUNCHER);
                shareIntent.setComponent(name);
                ctx.startActivity(shareIntent);
                break;
            }
        }
    } catch (final ActivityNotFoundException e) {
        Toast.makeText(ctx, "Could not find " + displayName + " app", Toast.LENGTH_SHORT).show();
    }

}

From source file:com.stepinmobile.fantasticbutton.api.ButtonHandle.java

/**
 * Method check network availability and open Google Play.
 *
 *///from  w ww. j a  v a 2 s .  c om
public void rateOnMarket() {
    if (!isNetworkAvailable()) {
        Toast.makeText(aq.getContext(), R.string.no_internet, Toast.LENGTH_LONG).show();
    } else {
        Activity ac = (Activity) aq.getContext();
        Uri uri = Uri.parse("market://details?id=" + ac.getPackageName());
        Intent goToMarket = new Intent(Intent.ACTION_VIEW, uri);
        try {
            ac.startActivity(goToMarket);
        } catch (ActivityNotFoundException e) {
            ac.startActivity(new Intent(Intent.ACTION_VIEW,
                    Uri.parse("http://play.google.com/store/apps/details?id=" + ac.getPackageName())));
        }
    }
}

From source file:com.amaze.filemanager.activities.Preferences.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:
        // Navigate "up" the demo structure to the launchpad activity.
        if (select == 1 && changed == 1)
            restartPC(this);
        else if (select == 1) {
            selectItem(0);/*w ww .j  a v a2s .  com*/
        } else {
            Intent in = new Intent(Preferences.this, MainActivity.class);
            in.setAction(Intent.ACTION_MAIN);
            final int enter_anim = android.R.anim.fade_in;
            final int exit_anim = android.R.anim.fade_out;
            Activity activity = this;
            activity.overridePendingTransition(enter_anim, exit_anim);
            activity.finish();
            activity.overridePendingTransition(enter_anim, exit_anim);
            activity.startActivity(in);
        }
        return true;

    }
    return true;
}

From source file:com.aokyu.dev.pocket.PocketClient.java

private void continueAuthorization(Activity callback, RequestToken requestToken) {
    String url = PocketServer.getRedirectUrl(mConsumerKey, requestToken);
    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
    intent.setFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP);
    callback.startActivity(intent);
}

From source file:com.apptentive.android.sdk.module.engagement.interaction.view.NavigateToLinkInteractionView.java

@Override
public void doOnCreate(Activity activity, Bundle savedInteraction) {
    boolean success = false;
    try {//from ww  w . j ava 2 s . c  o  m
        String url = interaction.getUrl();
        Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));

        switch (interaction.getTarget()) {
        case New:
            intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            break;
        case Self:
            // Nothing
            break;
        default:
            break;
        }

        activity.startActivity(intent);
        success = true;
    } catch (ActivityNotFoundException e) {
        Log.w("NavigateToLink Error: ", e);
    } finally {
        JSONObject data = new JSONObject();
        try {
            data.put(NavigateToLinkInteraction.KEY_URL, interaction.getUrl());
            data.put(NavigateToLinkInteraction.KEY_TARGET, interaction.getTarget().lowercaseName());
            data.put(NavigateToLinkInteraction.EVENT_KEY_SUCCESS, success);
        } catch (JSONException e) {
            Log.e("Error creating Event data object.", e);
        }
        EngagementModule.engageInternal(activity, interaction, NavigateToLinkInteraction.EVENT_NAME_NAVIGATE,
                data.toString());
        // Always finish this Activity.
        activity.finish();
    }
}

From source file:reportsas.com.formulapp.Formulario.java

public static void reiniciarActivity(Activity actividad, String parametro) {
    Intent intent = new Intent();

    intent.setClass(actividad, actividad.getClass());
    intent.putExtra("formulario", parametro);
    //llamamos a la actividad
    actividad.startActivity(intent);
    //finalizamos la actividad actual
    actividad.finish();/* w w  w  .  jav a2 s  .c om*/
}

From source file:com.adwhirl.AdWhirlLayout.java

@Override
public boolean onInterceptTouchEvent(MotionEvent event) {
    switch (event.getAction()) {
    // Sending on an ACTION_DOWN isn't 100% correct... user could have touched
    // down and dragged out. Unlikely though.
    case MotionEvent.ACTION_DOWN:
        Log.d(AdWhirlUtil.ADWHIRL, "Intercepted ACTION_DOWN event");
        if (activeRation != null) {
            countClick();/*from   www .j  av a2  s.  com*/

            if (activeRation.type == 9) {
                if (custom != null && custom.link != null) {
                    Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(custom.link));
                    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                    try {
                        if (activityReference == null) {
                            return false;
                        }
                        Activity activity = activityReference.get();
                        if (activity == null) {
                            return false;
                        }
                        activity.startActivity(intent);
                    } catch (Exception e) {
                        Log.w(AdWhirlUtil.ADWHIRL, "Could not handle click to " + custom.link, e);
                    }
                } else {
                    Log.w(AdWhirlUtil.ADWHIRL, "In onInterceptTouchEvent(), but custom or custom.link is null");
                }
            }
            break;
        }
    }

    // Return false so subViews can process event normally.
    return false;
}

From source file:com.android.browser.DownloadHandler.java

/**
 * Notify the host application a download should be done, or that
 * the data should be streamed if a streaming viewer is available.
 * @param activity Activity requesting the download.
 * @param url The full url to the content that should be downloaded
 * @param userAgent User agent of the downloading application.
 * @param contentDisposition Content-disposition http header, if present.
 * @param mimetype The mimetype of the content reported by the server
 * @param referer The referer associated with the downloaded url
 * @param privateBrowsing If the request is coming from a private browsing tab.
 *///from   www  .  ja  v  a  2 s.  c om
public static void onDownloadStart(Activity activity, String url, String userAgent, String contentDisposition,
        String mimetype, String referer, boolean privateBrowsing) {
    // if we're dealing wih A/V content that's not explicitly marked
    //     for download, check if it's streamable.
    if (contentDisposition == null || !contentDisposition.regionMatches(true, 0, "attachment", 0, 10)) {
        // query the package manager to see if there's a registered handler
        //     that matches.
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.setDataAndType(Uri.parse(url), mimetype);
        ResolveInfo info = activity.getPackageManager().resolveActivity(intent,
                PackageManager.MATCH_DEFAULT_ONLY);
        if (info != null) {
            ComponentName myName = activity.getComponentName();
            // If we resolved to ourselves, we don't want to attempt to
            // load the url only to try and download it again.
            if (!myName.getPackageName().equals(info.activityInfo.packageName)
                    || !myName.getClassName().equals(info.activityInfo.name)) {
                // someone (other than us) knows how to handle this mime
                // type with this scheme, don't download.
                try {
                    activity.startActivity(intent);
                    return;
                } catch (ActivityNotFoundException ex) {
                    if (LOGD_ENABLED) {
                        Log.d(LOGTAG,
                                "activity not found for " + mimetype + " over " + Uri.parse(url).getScheme(),
                                ex);
                    }
                    // Best behavior is to fall back to a download in this
                    // case
                }
            }
        }
    }
    onDownloadStartNoStream(activity, url, userAgent, contentDisposition, mimetype, referer, privateBrowsing);
}