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:org.getlantern.firetweet.util.Utils.java

public static void openUserListMemberships(final Activity activity, final long account_id, final long user_id,
        final String screen_name) {
    if (activity == null || account_id <= 0 || user_id <= 0 && isEmpty(screen_name))
        return;//ww w  .jav  a 2 s  .  c o  m
    final Uri.Builder builder = new Uri.Builder();
    builder.scheme(SCHEME_FIRETWEET);
    builder.authority(AUTHORITY_USER_LIST_MEMBERSHIPS);
    builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, String.valueOf(account_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);
    }
    final Intent intent = new Intent(Intent.ACTION_VIEW, builder.build());
    activity.startActivity(intent);
}

From source file:org.getlantern.firetweet.util.Utils.java

public static void openUserListDetails(final Activity activity, final ParcelableUserList userList) {
    if (activity == null || userList == null)
        return;/*from w w w  .  j a  v  a2  s .com*/
    final long accountId = userList.account_id, userId = userList.user_id;
    final long listId = userList.id;
    final Bundle extras = new Bundle();
    extras.putParcelable(EXTRA_USER_LIST, userList);
    final Uri.Builder builder = new Uri.Builder();
    builder.scheme(SCHEME_FIRETWEET);
    builder.authority(AUTHORITY_USER_LIST);
    builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, String.valueOf(accountId));
    builder.appendQueryParameter(QUERY_PARAM_USER_ID, String.valueOf(userId));
    builder.appendQueryParameter(QUERY_PARAM_LIST_ID, String.valueOf(listId));
    final Intent intent = new Intent(Intent.ACTION_VIEW, builder.build());
    intent.setExtrasClassLoader(activity.getClassLoader());
    intent.putExtras(extras);
    activity.startActivity(intent);
}

From source file:org.getlantern.firetweet.util.Utils.java

public static void openUserListMembers(final Activity activity, final long accountId, final long listId,
        final long userId, final String screenName, final String listName) {
    if (activity == null)
        return;//ww  w  .  j a  v  a 2 s.com
    final Uri.Builder builder = new Uri.Builder();
    builder.scheme(SCHEME_FIRETWEET);
    builder.authority(AUTHORITY_USER_LIST_MEMBERS);
    builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, String.valueOf(accountId));
    if (listId > 0) {
        builder.appendQueryParameter(QUERY_PARAM_LIST_ID, String.valueOf(listId));
    }
    if (userId > 0) {
        builder.appendQueryParameter(QUERY_PARAM_USER_ID, String.valueOf(userId));
    }
    if (screenName != null) {
        builder.appendQueryParameter(QUERY_PARAM_SCREEN_NAME, screenName);
    }
    if (listName != null) {
        builder.appendQueryParameter(QUERY_PARAM_LIST_NAME, listName);
    }
    final Intent intent = new Intent(Intent.ACTION_VIEW, builder.build());
    activity.startActivity(intent);
}

From source file:org.getlantern.firetweet.util.Utils.java

public static void openUserListTimeline(final Activity activity, final long accountId, final long listId,
        final long userId, final String screenName, final String listName) {
    if (activity == null)
        return;/*from   w w w  .  j av  a2 s. co m*/
    final Uri.Builder builder = new Uri.Builder();
    builder.scheme(SCHEME_FIRETWEET);
    builder.authority(AUTHORITY_USER_LIST_TIMELINE);
    builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, String.valueOf(accountId));
    if (listId > 0) {
        builder.appendQueryParameter(QUERY_PARAM_LIST_ID, String.valueOf(listId));
    }
    if (userId > 0) {
        builder.appendQueryParameter(QUERY_PARAM_USER_ID, String.valueOf(userId));
    }
    if (screenName != null) {
        builder.appendQueryParameter(QUERY_PARAM_SCREEN_NAME, screenName);
    }
    if (listName != null) {
        builder.appendQueryParameter(QUERY_PARAM_LIST_NAME, listName);
    }
    final Intent intent = new Intent(Intent.ACTION_VIEW, builder.build());
    activity.startActivity(intent);
}

From source file:org.getlantern.firetweet.util.Utils.java

public static void openUserListSubscribers(final Activity activity, final long accountId, final long listId,
        final long userId, final String screenName, final String listName) {
    if (activity == null)
        return;//from  w w  w  .ja va 2 s. c om
    final Uri.Builder builder = new Uri.Builder();
    builder.scheme(SCHEME_FIRETWEET);
    builder.authority(AUTHORITY_USER_LIST_SUBSCRIBERS);
    builder.appendQueryParameter(QUERY_PARAM_ACCOUNT_ID, String.valueOf(accountId));
    if (listId > 0) {
        builder.appendQueryParameter(QUERY_PARAM_LIST_ID, String.valueOf(listId));
    }
    if (userId > 0) {
        builder.appendQueryParameter(QUERY_PARAM_USER_ID, String.valueOf(userId));
    }
    if (screenName != null) {
        builder.appendQueryParameter(QUERY_PARAM_SCREEN_NAME, screenName);
    }
    if (listName != null) {
        builder.appendQueryParameter(QUERY_PARAM_LIST_NAME, listName);
    }
    final Intent intent = new Intent(Intent.ACTION_VIEW, builder.build());
    activity.startActivity(intent);
}

From source file:com.android.mms.ui.MessageUtils.java

public static void viewMmsMessageAttachment(final Activity activity, final Uri msgUri,
        final SlideshowModel slideshow, final int requestCode, AsyncDialog asyncDialog) {
    /// M: Code analyze 002, For fix bug ALPS00112553, system-server JE
    // happens and MS reboot when tap play in MMS. @{
    final boolean isSimple = (slideshow == null) ? false : slideshow.isSimple();

    if (isSimple) {
        SlideModel slideTemp = slideshow.get(0);
        // In attachment-editor mode, we only ever have one slide.
        /// M: fix bug ALPS00393187, play in gellay when simple slide only has picture or video
        if (slideTemp != null && !slideTemp.hasAudio()
                && (!slideTemp.hasText() || slideTemp.getText().getText().length() == 0)) {
            MessageUtils.viewSimpleSlideshow(activity, slideshow);
            return;
        }/*from ww w .j a  v  a  2s  .  c  o m*/
    }
    /// @}
    // M: change feature ALPS01751464
    if (isSimple) {
        SlideModel slideOne = slideshow.get(0);
        if (slideOne != null && slideOne.hasAudio()) {
            MediaModel model = slideOne.getAudio();
            if (model != null && model.hasDrmContent()) {
                DrmUtilsEx.showDrmAlertDialog(activity);
                return;
            }
        }
    }

    // The user wants to view the slideshow. We have to persist the slideshow parts
    // in a background task. If the task takes longer than a half second, a progress dialog
    // is displayed. Once the PDU persisting is done, another runnable on the UI thread get
    // executed to start the SlideshowActivity.
    asyncDialog.runAsync(new Runnable() {
        @Override
        public void run() {
            // If a slideshow was provided, save it to disk first.
            if (slideshow != null) {
                PduPersister persister = PduPersister.getPduPersister(activity);
                try {
                    PduBody pb = slideshow.toPduBody();
                    MessageUtils.updatePartsIfNeeded(slideshow, persister, msgUri, pb, null);
                    //persister.updateParts(msgUri, pb, null);
                    slideshow.sync(pb);
                } catch (MmsException e) {
                    Log.e(TAG, "Unable to save message for preview");
                    return;
                }
                slide = slideshow.get(0);
            }
        }
    }, new Runnable() {
        @Override
        public void run() {
            // Launch the slideshow activity to play/view.
            Intent intent;
            if ((isSimple && slide.hasAudio()) || (requestCode == AttachmentEditor.MSG_PLAY_AUDIO)) {
                intent = new Intent(activity.getApplicationContext(), SlideshowActivity.class);
            } else {
                intent = new Intent(activity.getApplicationContext(), MmsPlayerActivity.class);
            }
            intent.setData(msgUri);
            if (requestCode > 0) {
                activity.startActivityForResult(intent, requestCode);
            } else {
                activity.startActivity(intent);
            }
            //                    // Once the above background thread is complete, this runnable is run
            //                    // on the UI thread to launch the slideshow activity.
            //                    launchSlideshowActivity(activity, msgUri, requestCode);

        }
    }, R.string.building_slideshow_title);

}

From source file:carnero.cgeo.original.libs.Base.java

public void goHome(Activity activity) {
    final Intent intent = new Intent(activity, main.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

    activity.startActivity(intent);
    activity.finish();//from  w  ww .  j a v  a2s.c  o  m
}

From source file:ch.uzh.supersede.feedbacklibrary.utils.Utils.java

/**
 * This method opens the FeedbackActivity from the feedback library in case if a PULL feedback is triggered with a specific PULL configuration.
 *
 * @param baseURL                the base URL
 * @param activity               the activity in which the method is called
 * @param applicationId          the application id
 * @param language               the language
 * @param pullConfigurationId    the pull configuration id
 * @param intermediateDialogText the text to show in the intermediate dialog
 *//*from  w  w w  . ja  v  a2s . c  o  m*/
public static void triggerSpecificPullFeedback(@NonNull final String baseURL, @NonNull final Activity activity,
        final long applicationId, final @NonNull String language, final long pullConfigurationId,
        final @NonNull String intermediateDialogText) {
    Retrofit rtf = new Retrofit.Builder().baseUrl(baseURL).addConverterFactory(GsonConverterFactory.create())
            .build();
    feedbackAPI fbAPI = rtf.create(feedbackAPI.class);
    final Call<ResponseBody> checkUpAndRunning = fbAPI.pingOrchestrator();

    if (checkUpAndRunning != null) {
        checkUpAndRunning.enqueue(new Callback<ResponseBody>() {
            @Override
            public void onFailure(Call<ResponseBody> call, Throwable t) {
                Log.e(TAG, "Failed to ping the server. onFailure method called", t);
            }

            @Override
            public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
                if (response.code() == 200) {
                    Retrofit rtf = new Retrofit.Builder().baseUrl(baseURL)
                            .addConverterFactory(GsonConverterFactory.create()).build();
                    feedbackAPI fbAPI = rtf.create(feedbackAPI.class);
                    Call<OrchestratorConfigurationItem> result = fbAPI.getConfiguration(language,
                            applicationId);

                    // Asynchronous call
                    if (result != null) {
                        result.enqueue(new Callback<OrchestratorConfigurationItem>() {
                            @Override
                            public void onFailure(Call<OrchestratorConfigurationItem> call, Throwable t) {
                                Log.e(TAG, "Failed to retrieve the configuration. onFailure method called", t);
                                DialogUtils.showInformationDialog(activity,
                                        new String[] { activity.getResources().getString(
                                                R.string.supersede_feedbacklibrary_feedback_application_unavailable_text) },
                                        true);
                            }

                            @Override
                            public void onResponse(Call<OrchestratorConfigurationItem> call,
                                    Response<OrchestratorConfigurationItem> response) {
                                if (response.code() == 200) {
                                    Log.i(TAG, "Configuration successfully retrieved");
                                    OrchestratorConfigurationItem configuration = response.body();
                                    if (configuration != null) {
                                        List<ConfigurationItem> configurationItems = configuration
                                                .getConfigurationItems();
                                        long[] selectedPullConfigurationIndex = { -1L };
                                        ConfigurationItem selectedConfigurationItem = null;
                                        for (ConfigurationItem configurationItem : configurationItems) {
                                            if (configurationItem.getType().equals("PULL")
                                                    && configurationItem.getId() == pullConfigurationId) {
                                                selectedPullConfigurationIndex[0] = configurationItem.getId();
                                                selectedConfigurationItem = configurationItem;
                                                break;
                                            }
                                        }

                                        if (selectedPullConfigurationIndex[0] != -1
                                                && selectedConfigurationItem != null) {
                                            // If no "showIntermediateDialog" is provided, show it
                                            boolean showIntermediateDialog = true;
                                            for (Map<String, Object> parameter : selectedConfigurationItem
                                                    .getGeneralConfigurationItem().getParameters()) {
                                                String key = (String) parameter.get("key");
                                                // Intermediate dialog
                                                if (key.equals("showIntermediateDialog")) {
                                                    showIntermediateDialog = (Utils.intToBool(
                                                            ((Double) parameter.get("value")).intValue()));
                                                }
                                            }

                                            Intent intent = new Intent(activity, FeedbackActivity.class);
                                            String jsonString = new Gson().toJson(configuration);
                                            intent.putExtra(FeedbackActivity.IS_PUSH_STRING, false);
                                            intent.putExtra(FeedbackActivity.JSON_CONFIGURATION_STRING,
                                                    jsonString);
                                            intent.putExtra(
                                                    FeedbackActivity.SELECTED_PULL_CONFIGURATION_INDEX_STRING,
                                                    selectedPullConfigurationIndex[0]);
                                            intent.putExtra(FeedbackActivity.EXTRA_KEY_BASE_URL, baseURL);
                                            intent.putExtra(FeedbackActivity.EXTRA_KEY_LANGUAGE, language);
                                            if (!showIntermediateDialog) {
                                                // Start the feedback activity without asking the user
                                                activity.startActivity(intent);
                                            } else {
                                                // Ask the user if (s)he would like to give feedback or not
                                                DialogUtils.PullFeedbackIntermediateDialog d = DialogUtils.PullFeedbackIntermediateDialog
                                                        .newInstance(intermediateDialogText, jsonString,
                                                                selectedPullConfigurationIndex[0], baseURL,
                                                                language);
                                                d.show(activity.getFragmentManager(), "feedbackPopupDialog");
                                            }
                                        } else {
                                            DialogUtils.showInformationDialog(activity,
                                                    new String[] { activity.getResources().getString(
                                                            R.string.supersede_feedbacklibrary_feedback_application_unavailable_text) },
                                                    true);
                                        }
                                    }
                                } else {
                                    Log.e(TAG, "Failed to retrieve the configuration. Response code == "
                                            + response.code());
                                }
                            }
                        });
                    } else {
                        Log.e(TAG,
                                "Failed to retrieve the configuration. Call<OrchestratorConfigurationItem> result is null");
                    }
                } else {
                    Log.e(TAG, "The server is not up and running. Response code == " + response.code());
                }
            }
        });
    } else {
        Log.e(TAG, "Failed to ping the server. Call<ResponseBody> checkUpAndRunning result is null");
    }
}

From source file:carnero.cgeo.cgBase.java

public void goHome(Activity activity) {
    final Intent intent = new Intent(activity, cgeo.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

    activity.startActivity(intent);
    activity.finish();//  w w w .j av  a2 s  . com
}

From source file:carnero.cgeo.original.libs.Base.java

public boolean runNavigation(Activity activity, Resources res, Settings settings, Warning warning,
        GoogleAnalyticsTracker tracker, Double latitude, Double longitude, Double latitudeNow,
        Double longitudeNow) {//from   w w w .  ja  va 2  s .c om
    if (activity == null) {
        return false;
    }
    if (settings == null) {
        return false;
    }

    // Google Navigation
    if (settings.useGNavigation == 1) {
        try {
            activity.startActivity(new Intent(Intent.ACTION_VIEW,
                    Uri.parse("google.navigation:ll=" + latitude + "," + longitude)));

            sendAnal(activity, tracker, "/external/native/navigation");

            return true;
        } catch (Exception e) {
            // nothing
        }
    }

    // Google Maps Directions
    try {
        if (latitudeNow != null && longitudeNow != null) {
            activity.startActivity(
                    new Intent(Intent.ACTION_VIEW, Uri.parse("http://maps.google.com/maps?f=d&saddr="
                            + latitudeNow + "," + longitudeNow + "&daddr=" + latitude + "," + longitude)));
        } else {
            activity.startActivity(new Intent(Intent.ACTION_VIEW,
                    Uri.parse("http://maps.google.com/maps?f=d&daddr=" + latitude + "," + longitude)));
        }

        sendAnal(activity, tracker, "/external/native/maps");

        return true;
    } catch (Exception e) {
        // nothing
    }

    Log.i(Settings.tag, "cgBase.runNavigation: No navigation application available.");

    if (warning != null && res != null) {
        warning.showToast(res.getString(R.string.err_navigation_no));
    }

    return false;
}