List of usage examples for android.content Intent createChooser
public static Intent createChooser(Intent target, CharSequence title)
From source file:com.anysoftkeyboard.ui.SendBugReportUiActivity.java
public void onSendCrashReport(View v) { String[] recipients = new String[] { BuildConfig.CRASH_REPORT_EMAIL_ADDRESS }; Intent sendMail = new Intent(); sendMail.setAction(Intent.ACTION_SEND); sendMail.setType("plain/text"); sendMail.putExtra(Intent.EXTRA_EMAIL, recipients); sendMail.putExtra(Intent.EXTRA_SUBJECT, getText(R.string.ime_crashed_title)); sendMail.putExtra(Intent.EXTRA_TEXT, mCrashReportDetails.crashReportText); try {/*ww w . j av a2s . c o m*/ Intent sender = Intent.createChooser(sendMail, getString(R.string.ime_crashed_intent_selector_title)); sender.putExtra(Intent.EXTRA_EMAIL, sendMail.getStringArrayExtra(Intent.EXTRA_EMAIL)); sender.putExtra(Intent.EXTRA_SUBJECT, sendMail.getStringExtra(Intent.EXTRA_SUBJECT)); sender.putExtra(Intent.EXTRA_TEXT, mCrashReportDetails.crashReportText); Log.i(TAG, "Will send crash report using " + sender); startActivity(sender); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(getApplicationContext(), "Unable to send bug report via e-mail!", Toast.LENGTH_LONG) .show(); } finish(); }
From source file:cn.ieclipse.af.demo.MainActivity.java
@Override public void onCheckSuccess(final CheckUpdateController.CheckResponse info) { if (info != null) { DialogUtils.showAlert(this, android.R.drawable.ic_dialog_info, "?", TextUtils.isEmpty(info.description) ? "???" : info.description, new DialogInterface.OnClickListener() { @Override//w ww. ja v a 2 s . co m public void onClick(DialogInterface dialog, int which) { try { Intent intent = new Intent(Intent.ACTION_VIEW); intent.addCategory(Intent.CATEGORY_BROWSABLE); intent.addCategory(Intent.CATEGORY_DEFAULT); if (info.force) { intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); } intent.setData(Uri.parse(info.downloadLink)); startActivityForResult(Intent.createChooser(intent, null), 0x01); } catch (Exception e) { DialogUtils.showToast(getApplicationContext(), "?"); } finally { } } }, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (info.force) { finish(); } } }); } }
From source file:arun.com.chromer.webheads.ui.context.WebHeadContextActivity.java
@Override public void onWebSiteShare(@NonNull Website website) { startActivity(Intent.createChooser(TEXT_SHARE_INTENT.putExtra(EXTRA_TEXT, website.url), getString(R.string.share))); }
From source file:com.duy.ascii.sharedcode.image.ImageToAsciiActivity.java
private void selectImage() { if (!permissionGrated()) { return;//w w w .j a v a2s . c om } Intent getIntent = new Intent(Intent.ACTION_GET_CONTENT); getIntent.setType("image/*"); Intent pickIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI); pickIntent.setType("image/*"); Intent chooserIntent = Intent.createChooser(getIntent, "Select Image"); chooserIntent.putExtra(Intent.EXTRA_INITIAL_INTENTS, new Intent[] { pickIntent }); startActivityForResult(chooserIntent, PICK_IMAGE); }
From source file:com.autburst.picture.FinishedUploadActivity.java
private void sendLink() { String url = createVideoUrl(); if (url == null) { return;/* w ww . j ava 2 s . c o m*/ } Intent i = new Intent(Intent.ACTION_SEND); i.setType("text/plain"); Resources res = getResources(); i.putExtra(Intent.EXTRA_SUBJECT, res.getString(R.string.downloadlink)); i.putExtra(Intent.EXTRA_TEXT, url); startActivity(Intent.createChooser(i, res.getString(R.string.sendlink))); }
From source file:ca.ggolda.lendit.fragments.FragChat.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment View v = inflater.inflate(R.layout.activity_chat, container, false); // Get UserID mFirebaseAuth = FirebaseAuth.getInstance(); FirebaseUser user = mFirebaseAuth.getCurrentUser(); UserID = user.getUid();// w ww .j a va2 s . c om mUsername = user.getDisplayName(); mUsername = ANONYMOUS; mFirebaseDatabase = FirebaseDatabase.getInstance(); mUsername = user.getDisplayName(); mFirebaseStorage = FirebaseStorage.getInstance(); mMessagesDatabaseReference = mFirebaseDatabase.getReference().child("messages"); mChatPhotosStorageReference = mFirebaseStorage.getReference().child("chat_photos"); // Initialize references to views mProgressBar = (ProgressBar) v.findViewById(R.id.progressBar); mMessageListView = (ListView) v.findViewById(R.id.messageListView); mPhotoPickerButton = (ImageButton) v.findViewById(R.id.photoPickerButton); mMessageEditText = (EditText) v.findViewById(R.id.messageEditText); mSendButton = (Button) v.findViewById(R.id.sendButton); // Initialize message ListView and its adapter List<InstanceMessage> friendlyMessages = new ArrayList<>(); mMessageAdapter = new AdapterMessages(getContext(), R.layout.message_slide, friendlyMessages); mMessageListView.setAdapter(mMessageAdapter); // Initialize progress bar mProgressBar.setVisibility(ProgressBar.INVISIBLE); // ImagePickerButton shows an image picker to upload a image for a message mPhotoPickerButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("image/jpeg"); intent.putExtra(Intent.EXTRA_LOCAL_ONLY, true); startActivityForResult(Intent.createChooser(intent, "Complete action using"), RC_PHOTO_PICKER); } }); // Enable Send button when there's text to send mMessageEditText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { } @Override public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { if (charSequence.toString().trim().length() > 0) { mSendButton.setEnabled(true); } else { mSendButton.setEnabled(false); } } @Override public void afterTextChanged(Editable editable) { } }); mMessageEditText.setFilters(new InputFilter[] { new InputFilter.LengthFilter(DEFAULT_MSG_LENGTH_LIMIT) }); // Send button sends a message and clears the EditText mSendButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { // TODO: Send messages on click InstanceMessage friendlyMessage = new InstanceMessage(mMessageEditText.getText().toString(), mUsername, null); mMessagesDatabaseReference.push().setValue(friendlyMessage); // Clear input box mMessageEditText.setText(""); } }); mChildEventListener = new ChildEventListener() { @Override public void onChildAdded(DataSnapshot dataSnapshot, String s) { InstanceMessage friendlyMessage = dataSnapshot.getValue(InstanceMessage.class); mMessageAdapter.add(friendlyMessage); } @Override public void onChildChanged(DataSnapshot dataSnapshot, String s) { } @Override public void onChildRemoved(DataSnapshot dataSnapshot) { } @Override public void onChildMoved(DataSnapshot dataSnapshot, String s) { } @Override public void onCancelled(DatabaseError databaseError) { } }; mMessagesDatabaseReference.addChildEventListener(mChildEventListener); mAuthStateListener = new FirebaseAuth.AuthStateListener() { @Override public void onAuthStateChanged(@NonNull FirebaseAuth firebaseAuth) { FirebaseUser user = firebaseAuth.getCurrentUser(); if (user != null) { //user signed in OnSignedInInitialise(user.getDisplayName()); } else { //user signed out OnSignedOutCleanUp(); startActivityForResult( AuthUI.getInstance().createSignInIntentBuilder() .setProviders(AuthUI.EMAIL_PROVIDER, AuthUI.GOOGLE_PROVIDER).build(), RC_SIGN_IN); } } }; return v; }
From source file:in.animeshpathak.nextbus.NextBusMain.java
/** Called when the activity is first started. */ @Override/*from w ww .java2 s. c o m*/ public void onCreate(Bundle bundle) { Log.d(LOG_TAG, "entering onCreate()"); SettingsActivity.setTheme(this); super.onCreate(bundle); setContentView(R.layout.main); try { busNet = BusNetwork.getInstance(this); } catch (Exception e) { Log.e(LOG_TAG, e.getMessage(), e); return; } // get the button // set handler to launch a processing dialog ImageButton updateButton = (ImageButton) findViewById(R.id.update_button); updateButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { BusLine selectedLine = lineAdapter.getItem(lineSpinner.getSelectedItemPosition()); BusStop selectedStop = stopAdapter.getItem(stopSpinner.getSelectedItemPosition()); getBusTimings(selectedLine, selectedStop); } }); ImageButton feedbackButton = (ImageButton) findViewById(R.id.feedback_button); feedbackButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(Intent.ACTION_SEND); i.setType("message/rfc822"); // use from live device i.putExtra(Intent.EXTRA_EMAIL, new String[] { Constants.FEEDBACK_EMAIL_ADDRESS }); i.putExtra(Intent.EXTRA_SUBJECT, Constants.FEEDBACK_EMAIL_SUBJECT); i.putExtra(Intent.EXTRA_TEXT, getString(R.string.email_hello)); startActivity(Intent.createChooser(i, getString(R.string.select_email_app))); } }); ImageButton phebusinfoButton = (ImageButton) findViewById(R.id.phebusinfo_button); phebusinfoButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { AlertDialog alertDialog = new AlertDialog.Builder(NextBusMain.this).create(); WebView wv = new WebView(NextBusMain.this); new PhebusNewsLoader(wv, NextBusMain.this).execute(); alertDialog.setView(wv); alertDialog.show(); } }); lineSpinner = (Spinner) findViewById(R.id.line_spinner); lineAdapter = new ArrayAdapter<BusLine>(this, android.R.layout.simple_spinner_item, busNet.getLines()); lineAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); lineSpinner.setAdapter(lineAdapter); stopSpinner = (Spinner) findViewById(R.id.stop_spinner); stopAdapter = new ArrayAdapter<BusStop>(this, android.R.layout.simple_spinner_item); stopAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); stopSpinner.setAdapter(stopAdapter); ImageButton favoriteButton = (ImageButton) findViewById(R.id.favorites_button); favoriteButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View arg0) { new FavoriteDialog(NextBusMain.this, new OnFavoriteSelectedListener() { @Override public void favoriteSelected(Favorite fav) { BusLine bl = busNet.getLineByName(fav.getLine()); BusStop bs = bl.getFirstStopWithSimilarName(fav.getStop()); if (bl == null || bs == null) { Log.e(LOG_TAG, "Favorite not found!"); return; } updateSpinners(bl, bs); getBusTimings(bl, bs); } }, lineSpinner.getSelectedItem().toString(), stopSpinner.getSelectedItem().toString()); } }); }
From source file:com.davidmiguel.gobees.apiaries.ApiariesActivity.java
/** * Opens send feedback option./*from www . j a v a 2s . c o m*/ */ private void openSendFeedback() { Intent emailIntent = new Intent(Intent.ACTION_SENDTO, Uri.parse("mailto:" + getString(R.string.gobees_email))); emailIntent.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.gobees_email_subject)); emailIntent.putExtra(Intent.EXTRA_TEXT, getString(R.string.gobees_email_body)); startActivity(Intent.createChooser(emailIntent, getString(R.string.feedback_title))); }
From source file:co.taqat.call.AboutFragment.java
private void sendLogs(Context context, String info) { final String appName = context.getString(R.string.app_name); Intent i = new Intent(Intent.ACTION_SEND); i.putExtra(Intent.EXTRA_EMAIL, new String[] { context.getString(R.string.about_bugreport_email) }); i.putExtra(Intent.EXTRA_SUBJECT, appName + " Logs"); i.putExtra(Intent.EXTRA_TEXT, info); i.setType("application/zip"); try {//ww w . ja v a2 s . co m startActivity(Intent.createChooser(i, "Send mail...")); } catch (android.content.ActivityNotFoundException ex) { Log.e(ex); } }