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.filemanager.free.activities.Preferences.java

@Override
public void onBackPressed() {
    if (select == 1 && changed == 1)
        restartPC(this);
    else if (select == 1 || select == 2) {
        selectItem(0);/*from  w  ww. j ava 2 s .co m*/
    } 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);
    }
    MainActivity.showInterstitial();
}

From source file:com.filemanager.free.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 w w .  j  a va 2 s  . c om
        } 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);
        }
        MainActivity.showInterstitial();
        return true;

    }
    return true;
}

From source file:com.murrayc.galaxyzoo.app.SubjectExtrasFragment.java

private void doExamine() {
    final Activity activity = getActivity();

    //Open a link to the examine page:
    final String uriTalk = Config.EXAMINE_URI + getZooniverseId();

    final Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(uriTalk));
    activity.startActivity(intent);
}

From source file:com.jacr.instagramtrendreader.ImageDetailsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    ViewGroup view = (ViewGroup) inflater.inflate(R.layout.frg_images_details, container, false);

    // Views/*from   w  ww . j  a  v a  2s  . c  o  m*/
    TextView txtPublishDate = (TextView) view.findViewById(R.id.txtDateValue);
    TextView txtAuthor = (TextView) view.findViewById(R.id.txtUsernameValue);
    TextView txtTags = (TextView) view.findViewById(R.id.txtTagsValue);
    ImageView imv = (ImageView) view.findViewById(R.id.imvDetails);

    txtPublishDate.setText(formatearFecha(publishDate));
    txtAuthor.setText(author);
    txtTags.setText(tags);
    imv.setImageURI(Uri.fromFile(new File(imagePath)));
    imv.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            final Activity act = ImageDetailsFragment.this.getActivity();
            Intent in = new Intent(act, HTMLViewer.class);
            Bundle b = new Bundle();
            b.putString(HTMLViewer.KEY_USERNAME, author);
            b.putString(HTMLViewer.KEY_URL_IMAGE, urlDowloadImage);
            in.putExtras(b);
            act.startActivity(in);
        }

    });

    return view;
}

From source file:com.dmitrymalkovich.android.githubanalytics.Utils.java

public static void openFeedback(Activity activity) {
    try {//from  ww  w.j a v  a2s.  c  o m
        throw new IOException();
    } catch (IOException e) {
        ApplicationErrorReport report = new ApplicationErrorReport();
        report.packageName = report.processName = activity.getApplication().getPackageName();
        report.time = System.currentTimeMillis();
        report.type = ApplicationErrorReport.TYPE_CRASH;
        report.systemApp = false;
        ApplicationErrorReport.CrashInfo crash = new ApplicationErrorReport.CrashInfo();
        crash.exceptionClassName = e.getClass().getSimpleName();
        crash.exceptionMessage = e.getMessage();
        StringWriter writer = new StringWriter();
        PrintWriter printer = new PrintWriter(writer);
        e.printStackTrace(printer);
        crash.stackTrace = writer.toString();
        StackTraceElement stack = e.getStackTrace()[0];
        crash.throwClassName = stack.getClassName();
        crash.throwFileName = stack.getFileName();
        crash.throwLineNumber = stack.getLineNumber();
        crash.throwMethodName = stack.getMethodName();
        report.crashInfo = crash;
        Intent intent = new Intent(Intent.ACTION_APP_ERROR);
        intent.putExtra(Intent.EXTRA_BUG_REPORT, report);
        activity.startActivity(intent);
    }
}

From source file:com.android.gallery3d.ui.MenuExecutor.java

public void onMenuClicked(int action, ProgressListener listener, boolean waitOnStop, boolean showDialog) {
    int title;//w  w w  .  ja  va 2 s  .c o m
    switch (action) {
    case R.id.action_select_all:
        if (mSelectionManager.inSelectAllMode()) {
            mSelectionManager.deSelectAll();
        } else {
            mSelectionManager.selectAll();
        }
        return;
    case R.id.action_crop: {
        Intent intent = getIntentBySingleSelectedPath(CropActivity.CROP_ACTION);
        ((Activity) mActivity).startActivity(intent);
        return;
    }
    case R.id.action_edit: {
        Intent intent = getIntentBySingleSelectedPath(Intent.ACTION_EDIT)
                .setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        ((Activity) mActivity).startActivity(Intent.createChooser(intent, null));
        return;
    }
    case R.id.action_setas: {
        Intent intent = getIntentBySingleSelectedPath(Intent.ACTION_ATTACH_DATA)
                .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
        intent.putExtra("mimeType", intent.getType());
        Activity activity = mActivity;
        activity.startActivity(Intent.createChooser(intent, activity.getString(R.string.set_as)));
        return;
    }
    case R.id.action_delete:
        title = R.string.delete;
        break;
    case R.id.action_rotate_cw:
        title = R.string.rotate_right;
        break;
    case R.id.action_rotate_ccw:
        title = R.string.rotate_left;
        break;
    case R.id.action_show_on_map:
        title = R.string.show_on_map;
        break;
    default:
        return;
    }
    startAction(action, title, listener, waitOnStop, showDialog);
}

From source file:com.schedjoules.eventdiscovery.framework.actions.ShareActionExecutable.java

@Override
public void execute(@NonNull Activity activity) {
    new InsightsTask(activity).execute(new ActionInteraction(mLink, mEvent));

    String eventText = eventText(activity);

    Intent sendIntent = ShareCompat.IntentBuilder.from(activity).setText(eventText).setType("text/plain")
            .setChooserTitle(R.string.schedjoules_action_share_chooser_title).createChooserIntent();

    if (sendIntent.resolveActivity(activity.getPackageManager()) != null) {
        activity.startActivity(sendIntent);
    } else {/*from w  ww .  j a  va  2s  .c o m*/
        Toast.makeText(activity, R.string.schedjoules_action_cannot_handle_message, Toast.LENGTH_LONG).show();
    }
}

From source file:de.geeksfactory.opacclient.OpacClient.java

public void startVolumeSearch(Activity caller, Map<String, String> query) {
    Intent myIntent = new Intent(caller, SearchResultListActivity.class);
    myIntent.putExtra("volumeQuery", mapToBundle(query));
    caller.startActivity(myIntent);/*from  w  w  w .j a v  a 2 s  .  c  o  m*/
}

From source file:com.amaze.carbonfilemanager.activities.PreferencesActivity.java

public void restartPC(final Activity activity) {
    if (activity == null)
        return;/* ww w .ja v a  2s  .  c om*/
    final int enter_anim = android.R.anim.fade_in;
    final int exit_anim = android.R.anim.fade_out;
    activity.overridePendingTransition(enter_anim, exit_anim);
    activity.finish();
    activity.overridePendingTransition(enter_anim, exit_anim);
    activity.startActivity(activity.getIntent());
}

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

@Override
public void onBackPressed() {
    if (select == 1 && changed == 1)
        restartPC(this);
    else if (select == 1 || select == 2) {
        selectItem(0);//from   w  ww  .ja  v  a 2  s .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);
    }
}