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.scoreflex.Scoreflex.java

/**
 * Shows a Scoreflex panel on the provided activity.
 *
 * @param activity//from   ww w  . j a  v  a2 s  .  c om
 *            The activity that will host the view.
 * @param leaderboardId
 *            The leaderboard id of the rankbox that you want to show.
 * @param gravity
 *            Chooses if the view should be up are down of the screen.
 * @param params
 *            The parameter to be given to the resource (query string).
 * @param openAsActivity
 *            Tell wether or not the full view (when the rank panel is clicked)
 *            should be opened as a new activity
 */
public static ScoreflexView showRanksPanel(final Activity activity, String leaderboardId, int gravity,
        Scoreflex.RequestParams params, boolean openAsActivity) {
    // Resource
    String resource = String.format(Locale.getDefault(), "/web/scores/%s/ranks", leaderboardId);

    // Get the leaderboard & display
    ScoreflexView leaderboardView = Scoreflex.view(activity, resource, params, false);
    attachView(activity, leaderboardView, gravity);
    if (openAsActivity) {
        leaderboardView.setScoreflexViewListener(new ScoreflexViewListener() {

            @Override
            public void onViewClosed() {

            }

            @Override
            public boolean handleOpenNewFullscreenView(String fullUrlString) {
                Intent intent = new Intent(activity, ScoreflexActivity.class);
                intent.putExtra(ScoreflexActivity.INTENT_SHOW_EXTRA_KEY,
                        ScoreflexActivity.INTENT_EXTRA_SHOW_ABSTRACT_URL);
                intent.putExtra(ScoreflexActivity.INTENT_EXTRA_ABSTRACT_URL, fullUrlString);
                activity.startActivity(intent);
                return true;
            }

        });
    }
    return leaderboardView;
}

From source file:com.dwdesign.tweetings.fragment.BaseUserListsListFragment.java

private void openUserListDetails(final Activity activity, final long account_id, final int list_id,
        final long user_id, final String screen_name, final String list_name) {
    if (activity == null)
        return;/*from  w  ww  . j  a va  2  s  . c o m*/
    if (activity instanceof HomeActivity && ((HomeActivity) activity).isDualPaneMode()) {
        final HomeActivity home_activity = (HomeActivity) activity;
        if (mDetailFragment instanceof UserProfileFragment && mDetailFragment.isAdded()) {
            ((UserProfileFragment) mDetailFragment).getUserInfo(mAccountId, user_id, screen_name);
        } else {
            mDetailFragment = new UserListDetailsFragment();
            final Bundle args = new Bundle();
            args.putLong(INTENT_KEY_ACCOUNT_ID, account_id);
            args.putInt(INTENT_KEY_LIST_ID, list_id);
            args.putLong(INTENT_KEY_USER_ID, user_id);
            args.putString(INTENT_KEY_SCREEN_NAME, screen_name);
            args.putString(INTENT_KEY_LIST_NAME, list_name);
            mDetailFragment.setArguments(args);
            home_activity.showAtPane(HomeActivity.PANE_RIGHT, mDetailFragment, true);
        }
    } else {
        final Uri.Builder builder = new Uri.Builder();
        builder.scheme(SCHEME_TWEETINGS);
        builder.authority(AUTHORITY_LIST_DETAILS);
        builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, String.valueOf(account_id));
        if (list_id > 0) {
            builder.appendQueryParameter(QUERY_PARAM_LIST_ID, String.valueOf(list_id));
        }
        if (user_id > 0) {
            builder.appendQueryParameter(QUERY_PARAM_USER_ID, String.valueOf(user_id));
        }
        if (screen_name != null) {
            builder.appendQueryParameter(QUERY_PARAM_SCREEN_NAME, screen_name);
        }
        if (list_name != null) {
            builder.appendQueryParameter(QUERY_PARAM_LIST_NAME, list_name);
        }
        activity.startActivity(new Intent(Intent.ACTION_VIEW, builder.build()));
    }
}

From source file:com.amaze.carbonfilemanager.fragments.MainFragment.java

public static void launchSMB(final SmbFile smbFile, final long si, final Activity activity) {
    final Streamer s = Streamer.getInstance();
    new Thread() {
        public void run() {
            try {
                /*//w ww.  j  a  v a2s  . c om
                List<SmbFile> subtitleFiles = new ArrayList<SmbFile>();
                        
                // finding subtitles
                for (Layoutelements layoutelement : LIST_ELEMENTS) {
                SmbFile smbFile = new SmbFile(layoutelement.getDesc());
                if (smbFile.getName().contains(smbFile.getName())) subtitleFiles.add(smbFile);
                }
                */

                s.setStreamSrc(smbFile, si);
                activity.runOnUiThread(new Runnable() {
                    public void run() {
                        try {
                            Uri uri = Uri.parse(Streamer.URL
                                    + Uri.fromFile(new File(Uri.parse(smbFile.getPath()).getPath()))
                                            .getEncodedPath());
                            Intent i = new Intent(Intent.ACTION_VIEW);
                            i.setDataAndType(uri, MimeTypes.getMimeType(new File(smbFile.getPath())));
                            PackageManager packageManager = activity.getPackageManager();
                            List<ResolveInfo> resInfos = packageManager.queryIntentActivities(i, 0);
                            if (resInfos != null && resInfos.size() > 0)
                                activity.startActivity(i);
                            else
                                Toast.makeText(activity,
                                        activity.getResources().getString(R.string.smb_launch_error),
                                        Toast.LENGTH_SHORT).show();
                        } catch (ActivityNotFoundException e) {
                            e.printStackTrace();
                        }
                    }
                });

            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }.start();
}

From source file:com.dwdesign.tweetings.util.Utils.java

public static void restartActivity(final Activity activity, final boolean animation) {
    if (activity == null)
        return;//from   ww w .j  a  v  a  2s  .c  om
    final int enter_anim = animation ? android.R.anim.fade_in : 0;
    final int exit_anim = animation ? android.R.anim.fade_out : 0;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) {
        OverridePendingTransitionAccessor.overridePendingTransition(activity, enter_anim, exit_anim);
    } else {
        activity.getWindow().setWindowAnimations(0);
    }
    activity.finish();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR) {
        OverridePendingTransitionAccessor.overridePendingTransition(activity, enter_anim, exit_anim);
    } else {
        activity.getWindow().setWindowAnimations(0);
    }
    activity.startActivity(activity.getIntent());
}

From source file:com.saulcintero.moveon.fragments.History.java

public static void sendAction(final Activity act, int[] idList, String[] nameList, String[] activityList,
        String[] shortDescriptionList, String[] longDescriptionList) {
    ArrayList<Integer> positions = new ArrayList<Integer>();
    for (int p = 0; p < idList.length; p++) {
        String nameToSearch = osmFilesNameFromUploadPosition.get(p).substring(0,
                osmFilesNameFromUploadPosition.get(p).length() - 4);
        positions.add(ArrayUtils.indexOf(listOfFiles, nameToSearch));
    }//w  ww .  j a  v a2  s  .  co m

    for (int j = 0; j < idList.length; j++) {
        final String name = nameList[j];
        final String activity = activityList[j];
        final String shortDescription = shortDescriptionList[j];
        final String longDescription = longDescriptionList[j];
        final String url = osmUrlsToShare.get(positions.get(j));
        Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND);
        sendIntent.setType("text/plain");
        List<ResolveInfo> activities = act.getPackageManager().queryIntentActivities(sendIntent, 0);
        AlertDialog.Builder builder = new AlertDialog.Builder(act);
        builder.setTitle(act.getText(R.string.send_to) + " " + name + " " + act.getText(R.string.share_with));
        final ShareIntentListAdapter adapter = new ShareIntentListAdapter(act, R.layout.social_share,
                activities.toArray());
        builder.setAdapter(adapter, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                ResolveInfo info = (ResolveInfo) adapter.getItem(which);
                if (info.activityInfo.packageName.contains("facebook")) {
                    Intent i = new Intent("android.intent.action.PUBLISH_TO_FB_WALL");
                    i.putExtra("name", activity + " " + name);
                    i.putExtra("msg", String.format("%s", shortDescription));
                    i.putExtra("link", String.format("%s", url));
                    act.sendBroadcast(i);
                } else {
                    Intent intent = new Intent(android.content.Intent.ACTION_SEND);
                    intent.setClassName(info.activityInfo.packageName, info.activityInfo.name);
                    intent.setType("text/plain");
                    if ((info.activityInfo.packageName.contains("twitter"))
                            || (info.activityInfo.packageName.contains("sms"))
                            || (info.activityInfo.packageName.contains("mms"))) {
                        intent.putExtra(Intent.EXTRA_TEXT, shortDescription + url);
                    } else {
                        intent.putExtra(Intent.EXTRA_TEXT, longDescription + url);
                    }
                    act.startActivity(intent);
                }
            }
        });
        builder.create().show();
    }
}

From source file:com.dwdesign.tweetings.util.Utils.java

public static void openTrends(final Activity activity, final long account_id) {
    if (activity == null)
        return;//from  w  ww. j a  v  a 2 s. c o  m
    if (activity instanceof DualPaneActivity && ((DualPaneActivity) activity).isDualPaneMode()) {
        final DualPaneActivity dual_pane_activity = (DualPaneActivity) activity;
        final Fragment fragment = new TrendsFragment();
        final Bundle args = new Bundle();
        args.putLong(INTENT_KEY_ACCOUNT_ID, account_id);
        fragment.setArguments(args);
        dual_pane_activity.showAtPane(DualPaneActivity.PANE_LEFT, fragment, true);
    } else {
        final Uri.Builder builder = new Uri.Builder();
        builder.scheme(SCHEME_TWEETINGS);
        builder.authority(AUTHORITY_TRENDS);
        builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, String.valueOf(account_id));
        activity.startActivity(new Intent(Intent.ACTION_VIEW, builder.build()));
    }
}

From source file:com.filemanager.free.activities.MainActivity.java

@SuppressLint("InflateParams")
private void initialiseViews() {
    mCoordinatorLayout = (CoordinatorLayout) findViewById(R.id.main_frame);
    appBarLayout = (AppBarLayout) findViewById(R.id.lin);
    if (!ImageLoader.getInstance().isInited()) {
        ImageLoader.getInstance().init(ImageLoaderConfiguration.createDefault(this));
    }/*from www  . j  a v  a 2 s . co  m*/
    if (displayImageOptions != null) {
        displayImageOptions = new DisplayImageOptions.Builder().showImageOnLoading(R.drawable.amaze_header)
                .showImageForEmptyUri(R.drawable.amaze_header).showImageOnFail(R.drawable.amaze_header)
                .cacheInMemory(true).cacheOnDisk(true).considerExifParams(true)
                .bitmapConfig(Bitmap.Config.RGB_565).build();
    }

    buttonBarFrame = (FrameLayout) findViewById(R.id.buttonbarframe);
    buttonBarFrame.setBackgroundColor(Color.parseColor(skin));
    drawerHeaderLayout = getLayoutInflater().inflate(R.layout.drawerheader, null);
    drawerHeaderParent = (RelativeLayout) drawerHeaderLayout.findViewById(R.id.drawer_header_parent);
    drawerHeaderView = (View) drawerHeaderLayout.findViewById(R.id.drawer_header);
    drawerHeaderView.setOnLongClickListener(new View.OnLongClickListener() {
        @Override
        public boolean onLongClick(View v) {
            Intent intent;
            if (Build.VERSION.SDK_INT < 19) {
                intent = new Intent();
                intent.setAction(Intent.ACTION_GET_CONTENT);
            } else {
                intent = new Intent(Intent.ACTION_OPEN_DOCUMENT);

            }
            intent.addCategory(Intent.CATEGORY_OPENABLE);
            intent.setType("image/*");
            startActivityForResult(intent, image_selector_request_code);
            return false;
        }
    });
    drawerProfilePic = (RoundedImageView) drawerHeaderLayout.findViewById(R.id.profile_pic);
    mGoogleName = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_name);
    mGoogleId = (TextView) drawerHeaderLayout.findViewById(R.id.account_header_drawer_email);
    toolbar = (Toolbar) findViewById(R.id.action_bar);
    setSupportActionBar(toolbar);
    frameLayout = (FrameLayout) findViewById(R.id.content_frame);
    indicator_layout = findViewById(R.id.indicator_layout);
    mDrawerLinear = (ScrimInsetsRelativeLayout) findViewById(R.id.left_drawer);
    if (theme1 == 1)
        mDrawerLinear.setBackgroundColor(Color.parseColor("#303030"));
    else {
        assert mDrawerLinear != null;
        mDrawerLinear.setBackgroundColor(Color.WHITE);
    }
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerLayout.setStatusBarBackgroundColor(Color.parseColor(skin));
    mDrawerList = (ListView) findViewById(R.id.menu_drawer);
    drawerHeaderView.setBackgroundResource(R.drawable.amaze_header);
    drawerHeaderParent.setBackgroundColor(Color.parseColor(skin));
    if (findViewById(R.id.tab_frame) != null) {
        mDrawerLayout.setDrawerLockMode(DrawerLayout.LOCK_MODE_LOCKED_OPEN, mDrawerLinear);
        mDrawerLayout.setScrimColor(Color.TRANSPARENT);
        isDrawerLocked = true;
    }
    mDrawerList.addHeaderView(drawerHeaderLayout);
    if (getSupportActionBar() != null) {
        getSupportActionBar().setDisplayShowTitleEnabled(false);
    }

    View v = findViewById(R.id.fab_bg);
    if (theme1 == 1) {
        assert v != null;
        v.setBackgroundColor(Color.parseColor("#a6ffffff"));
    }

    assert v != null;
    v.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            floatingActionButton.close(true);
            utils.revealShow(view, false);
        }
    });

    pathbar = (LinearLayout) findViewById(R.id.pathbar);
    buttons = (LinearLayout) findViewById(R.id.buttons);
    scroll = (HorizontalScrollView) findViewById(R.id.scroll);
    scroll1 = (HorizontalScrollView) findViewById(R.id.scroll1);
    scroll.setSmoothScrollingEnabled(true);
    scroll1.setSmoothScrollingEnabled(true);
    ImageView divider = (ImageView) findViewById(R.id.divider1);
    if (theme1 == 0) {
        assert divider != null;
        divider.setImageResource(R.color.divider);
    } else {
        assert divider != null;
        divider.setImageResource(R.color.divider_dark);
    }

    setDrawerHeaderBackground();
    View settingsbutton = findViewById(R.id.settingsbutton);
    if (theme1 == 1) {
        assert settingsbutton != null;
        settingsbutton.setBackgroundResource(R.drawable.safr_ripple_black);
        ((ImageView) settingsbutton.findViewById(R.id.settingicon))
                .setImageResource(R.drawable.ic_settings_white_48dp);
        ((TextView) settingsbutton.findViewById(R.id.settingtext))
                .setTextColor(ContextCompat.getColor(con, android.R.color.white));
    }
    assert settingsbutton != null;
    settingsbutton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Intent in = new Intent(MainActivity.this, Preferences.class);
            finish();
            final int enter_anim = android.R.anim.fade_in;
            final int exit_anim = android.R.anim.fade_out;
            Activity s = MainActivity.this;
            s.overridePendingTransition(exit_anim, enter_anim);
            s.finish();
            s.overridePendingTransition(enter_anim, exit_anim);
            s.startActivity(in);
        }

    });
    View appbutton = findViewById(R.id.appbutton);
    if (theme1 == 1) {
        assert appbutton != null;
        appbutton.setBackgroundResource(R.drawable.safr_ripple_black);
        ((ImageView) appbutton.findViewById(R.id.appicon)).setImageResource(R.drawable.ic_doc_apk_white);
        ((TextView) appbutton.findViewById(R.id.apptext))
                .setTextColor(ContextCompat.getColor(con, android.R.color.white));
    }
    assert appbutton != null;
    appbutton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            android.support.v4.app.FragmentTransaction transaction2 = getSupportFragmentManager()
                    .beginTransaction();
            transaction2.replace(R.id.content_frame, new AppsList());
            findViewById(R.id.lin).animate().translationY(0).setInterpolator(new DecelerateInterpolator(2))
                    .start();
            pending_fragmentTransaction = transaction2;
            if (!isDrawerLocked)
                mDrawerLayout.closeDrawer(mDrawerLinear);
            else
                onDrawerClosed();
            select = -2;
            adapter.toggleChecked(false);
        }
    });
    getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(skin)));

    // status bar0
    sdk = Build.VERSION.SDK_INT;

    if (sdk == 20 || sdk == 19) {
        SystemBarTintManager tintManager = new SystemBarTintManager(this);
        tintManager.setStatusBarTintEnabled(true);
        tintManager.setStatusBarTintColor(Color.parseColor(skin));
        FrameLayout.MarginLayoutParams p = (ViewGroup.MarginLayoutParams) findViewById(R.id.drawer_layout)
                .getLayoutParams();
        SystemBarTintManager.SystemBarConfig config = tintManager.getConfig();
        if (!isDrawerLocked)
            p.setMargins(0, config.getStatusBarHeight(), 0, 0);
    } else if (Build.VERSION.SDK_INT >= 21) {
        colourednavigation = Sp.getBoolean("colorednavigation", true);

        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        //window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        if (isDrawerLocked) {
            window.setStatusBarColor((skinStatusBar));
        } else
            window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        if (colourednavigation)
            window.setNavigationBarColor(skinStatusBar);

    }
    //admob
    mAdView = (View) findViewById(R.id.ads);
}

From source file:com.dwdesign.tweetings.util.Utils.java

public static void openUserBlocks(final Activity activity, final long account_id) {
    if (activity == null)
        return;/*from  ww w .j  a v  a  2  s  .  c o  m*/
    if (activity instanceof DualPaneActivity && ((DualPaneActivity) activity).isDualPaneMode()) {
        final DualPaneActivity dual_pane_activity = (DualPaneActivity) activity;
        final Fragment fragment = new UserBlocksListFragment();
        final Bundle args = new Bundle();
        args.putLong(INTENT_KEY_ACCOUNT_ID, account_id);
        fragment.setArguments(args);
        dual_pane_activity.showAtPane(DualPaneActivity.PANE_LEFT, fragment, true);
    } else {
        final Uri.Builder builder = new Uri.Builder();
        builder.scheme(SCHEME_TWEETINGS);
        builder.authority(AUTHORITY_USER_BLOCKS);
        builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, String.valueOf(account_id));
        activity.startActivity(new Intent(Intent.ACTION_VIEW, builder.build()));
    }
}

From source file:com.dwdesign.tweetings.util.Utils.java

public static void openRetweetsOfMe(final Activity activity, final long account_id) {
    if (activity == null)
        return;/*from w  w w .j  a  v  a2 s.c  o m*/
    if (activity instanceof DualPaneActivity && ((DualPaneActivity) activity).isDualPaneMode()) {
        final DualPaneActivity dual_pane_activity = (DualPaneActivity) activity;
        final Fragment fragment = new RetweetedToMeFragment();
        final Bundle args = new Bundle();
        args.putLong(INTENT_KEY_ACCOUNT_ID, account_id);
        fragment.setArguments(args);
        dual_pane_activity.showAtPane(DualPaneActivity.PANE_LEFT, fragment, true);
    } else {
        final Uri.Builder builder = new Uri.Builder();
        builder.scheme(SCHEME_TWEETINGS);
        builder.authority(AUTHORITY_RETWEETED_TO_ME);
        builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, String.valueOf(account_id));
        activity.startActivity(new Intent(Intent.ACTION_VIEW, builder.build()));
    }
}

From source file:com.dwdesign.tweetings.util.Utils.java

public static void openSavedSearches(final Activity activity, final long account_id) {
    if (activity == null)
        return;/*from   www .  j  av  a2  s.  c  om*/
    if (activity instanceof DualPaneActivity && ((DualPaneActivity) activity).isDualPaneMode()) {
        final DualPaneActivity dual_pane_activity = (DualPaneActivity) activity;
        final Fragment fragment = new SavedSearchesListFragment();
        final Bundle args = new Bundle();
        args.putLong(INTENT_KEY_ACCOUNT_ID, account_id);
        fragment.setArguments(args);
        dual_pane_activity.showAtPane(DualPaneActivity.PANE_LEFT, fragment, true);
    } else {
        final Uri.Builder builder = new Uri.Builder();
        builder.scheme(SCHEME_TWEETINGS);
        builder.authority(AUTHORITY_SAVED_SEARCHES);
        builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, String.valueOf(account_id));
        activity.startActivity(new Intent(Intent.ACTION_VIEW, builder.build()));
    }
}