List of usage examples for android.app Activity startActivity
@Override public void startActivity(Intent intent)
From source file:com.crearo.gpslogger.ui.fragments.display.GpsSimpleViewFragment.java
private void startInstalledAppDetailsActivity(final Activity context) { if (context == null) { return;/*from w w w . j a v a 2 s.c o m*/ } final Intent i = new Intent(); i.setAction(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); i.addCategory(Intent.CATEGORY_DEFAULT); i.setData(Uri.parse("package:" + context.getPackageName())); i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); i.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); i.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS); context.startActivity(i); }
From source file:de.wikilab.android.friendica01.Max.java
/** * displays the login form (layout/loginscreen.xml) as a modal dialog and calls tryLogin * when user confirms the form/*w w w . ja v a 2 s . co m*/ * @param ctx MUST IMPLEMENT LoginListener !!! * @param errmes message which is displayed above the Login form (e.g. "wrong password entered") */ public static void showLoginForm(final Activity ctx, String errmes) { Log.v(TAG, "... showLoginForm"); View myView = ctx.getLayoutInflater().inflate(R.layout.loginscreen, null, false); final AlertDialog alert = new AlertDialog.Builder(ctx).setTitle("Login to Friendica").setView(myView) .setOnCancelListener(new OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { ctx.finish(); } }).show(); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx); String protocol = prefs.getString("login_protocol", "https"); String server = prefs.getString("login_server", null); String userName = prefs.getString("login_user", null); if (errmes != null) { ((TextView) myView.findViewById(R.id.lblInfo)).setText(errmes); } final Spinner selProtocol = (Spinner) myView.findViewById(R.id.selProtocol); selProtocol.setSelection(protocol.equals("https") ? 1 : 0); //HACK !!! final EditText edtServer = (EditText) myView.findViewById(R.id.edtServer); edtServer.setText(server); final EditText edtUser = (EditText) myView.findViewById(R.id.edtUser); edtUser.setText(userName); final EditText edtPassword = (EditText) myView.findViewById(R.id.edtPassword); ((TextView) myView.findViewById(R.id.proxy_settings)).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { ctx.startActivity(new Intent(ctx, PreferencesActivity.class)); } }); ((Button) myView.findViewById(R.id.button1)).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { SharedPreferences.Editor prefs = PreferenceManager.getDefaultSharedPreferences(ctx).edit(); prefs.putString("login_protocol", selProtocol.getSelectedItem().toString()); String server = edtServer.getText().toString(); server = server.replaceAll("^https?://", ""); prefs.putString("login_server", server); prefs.putString("login_user", edtUser.getText().toString()); prefs.putString("login_password", edtPassword.getText().toString()); prefs.commit(); alert.dismiss(); tryLogin(ctx); } }); }
From source file:com.halzhang.android.apps.startupnews.ui.SNApiHelper.java
/** * //from w ww . j a v a 2 s . co m * @param postID {@link SNNew#getPostID()} */ public void upVote(String postID) { final Activity activity = mActivityRef.get(); if (activity == null) { return; } SessionManager sm = SessionManager.getInstance(activity); if (sm.isValid()) { SNApi api = new SNApi(activity); final String url = activity.getString(R.string.vote_url, postID, sm.getSessionId(), sm.getSessionUser()); api.upVote(url, new AsyncHttpResponseHandler() { @Override public void onSuccess(int statusCode, String content) { if (statusCode == HttpStatus.SC_OK && TextUtils.isEmpty(content)) { CDToast.showToast(activity, R.string.tip_vote_success); } else { EasyTracker.getTracker().sendEvent("ui_action_feedback", "upvote_feedback", content, 0L); if (content.contains("mismatch")) { // cookie activity.startActivity(new Intent(activity, LoginActivity.class)); CDToast.showToast(activity, R.string.tip_cookie_invalid); } else { CDToast.showToast(activity, activity.getString(R.string.tip_vote_duplicate)); } } } @Override public void onFailure(Throwable error, String content) { EasyTracker.getTracker().sendException("up vote error:" + content, error, false); CDToast.showToast(activity, activity.getString(R.string.tip_vote_failure)); } }); } else { Intent intent = new Intent(activity, LoginActivity.class); activity.startActivity(intent); } }
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);// ww w .ja v a2s.com 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); }
From source file:br.com.viniciuscr.notification2android.mediaPlayer.MusicUtils.java
static void activateTab(Activity a, int id) { Intent intent = new Intent(Intent.ACTION_PICK); switch (id) { case R.id.artisttab: intent.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/artistalbum"); break;/* ww w .j av a 2 s . c o m*/ case R.id.albumtab: intent.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/album"); break; case R.id.songtab: intent.setDataAndType(Uri.EMPTY, "vnd.android.cursor.dir/track"); break; case R.id.playlisttab: intent.setDataAndType(Uri.EMPTY, MediaStore.Audio.Playlists.CONTENT_TYPE); break; case R.id.nowplaying: // intent = new Intent(a, MediaPlaybackActivity.class); // a.startActivity(intent); // fall through and return default: return; } intent.putExtra("withtabs", true); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); a.startActivity(intent); a.finish(); a.overridePendingTransition(0, 0); }
From source file:dk.dr.radio.data.DRData.java
public void kundividi(Activity akt) { Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_SUBJECT, "Esperanto-radio por Androjd"); sendIntent.putExtra(Intent.EXTRA_TEXT, "Saluton!\n\n" + "Mi rekomendas ke vi elprovas tiun i programon per via Androjda telefono:\n" + "La Esperanto-radio de Muzaiko\n" + "https://market.android.com/details?id=dk.nordfalk.esperanto.radio\n" + "\n" + "Muzaiko estas Esperanto-radio kiu konstante elsendas.\n" + "Eblas anka askulti la lastatempajn elsendojn de deko da aliaj radistacioj." // +"\n\n(kaj... ne forgesu meti 5 stelojn :-)" );// w w w . ja va2s . co m sendIntent.setType("text/plain"); akt.startActivity(Intent.createChooser(sendIntent, "Sendi al")); }
From source file:com.android.launcher3.Utilities.java
private static void applyChange(Activity context) { context.finish();//from ww w . j a va2 s . c o m context.startActivity(new Intent(Intent.ACTION_MAIN).addCategory(Intent.CATEGORY_LAUNCHER) .addCategory(Intent.CATEGORY_DEFAULT).addCategory(Intent.CATEGORY_HOME)); }
From source file:com.fa.imaged.activity.DetailActivityV2.java
public void viewProfile(Activity activity, InstagramImage data) { Intent profile = new Intent(activity, ProfileActivity.class); profile.putExtra("profile_page", data.user_id); profile.putExtra("profile_picture", data.profile_picture); profile.putExtra("profile_name", data.full_name); profile.putExtra("profile_uname", data.username); profile.putExtra("profile_posts", 0); profile.putExtra("profile_follows", 0); profile.putExtra("profile_following", 0); // start the new activity activity.startActivity(profile); }
From source file:ch.uzh.supersede.feedbacklibrary.utils.Utils.java
private static void startActivity(@NonNull final Activity activity, @NonNull final Intent intent, @NonNull String baseURL, final boolean isCapturingScreenshot) { Retrofit rtf = new Retrofit.Builder().baseUrl(baseURL).addConverterFactory(GsonConverterFactory.create()) .build();/*from w w w . ja v a 2s .c o m*/ feedbackAPI fbAPI = rtf.create(feedbackAPI.class); 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); DialogUtils.showInformationDialog(activity, new String[] { activity.getResources().getString( R.string.supersede_feedbacklibrary_feedback_application_unavailable_text) }, true); } @Override public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) { if (response.code() == 200) { if (isCapturingScreenshot) { String defaultImagePath = captureScreenshot(activity); intent.putExtra(FeedbackActivity.DEFAULT_IMAGE_PATH, defaultImagePath); } activity.startActivity(intent); } else { Log.e(TAG, "The server is not up and running. Response code == " + response.code()); DialogUtils.showInformationDialog(activity, new String[] { activity.getResources().getString( R.string.supersede_feedbacklibrary_feedback_application_unavailable_text) }, true); } } }); } else { Log.e(TAG, "Failed to ping the server. Call<ResponseBody> checkUpAndRunning result is null"); DialogUtils.showInformationDialog(activity, new String[] { activity.getResources() .getString(R.string.supersede_feedbacklibrary_feedback_application_unavailable_text) }, true); } }
From source file:com.mobicage.rogerthat.util.ui.UIUtils.java
public static void showErrorDialog(final Activity activity, Intent intent) { final String errorMessage = intent.getStringExtra(ERROR_MESSAGE); if (TextUtils.isEmptyOrWhitespace(errorMessage)) { activity.finish();/* w w w . j av a 2 s . co m*/ UIUtils.showErrorToast(activity, activity.getString(R.string.scanner_communication_failure)); } else { final String errorCaption = intent.getStringExtra(ERROR_CAPTION); final String errorAction = intent.getStringExtra(ERROR_ACTION); final String errorTitle = intent.getStringExtra(ERROR_TITLE); SafeDialogClick positiveButtonListener = new SafeDialogClick() { @Override public void safeOnClick(DialogInterface dialog, int id) { dialog.dismiss(); activity.finish(); } }; SafeDialogClick negativeButtonListener = null; if (!TextUtils.isEmptyOrWhitespace(errorCaption) && !TextUtils.isEmptyOrWhitespace(errorAction)) { negativeButtonListener = new SafeDialogClick() { @Override public void safeOnClick(DialogInterface dialog, int id) { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(errorAction)); dialog.dismiss(); activity.finish(); activity.startActivity(intent); } }; } UIUtils.showDialog(activity, errorTitle, errorMessage, positiveButtonListener, errorCaption, negativeButtonListener); } }