List of usage examples for android.content Intent setType
public @NonNull Intent setType(@Nullable String type)
From source file:markson.visuals.sitapp.eventActivity.java
public void addtocal() throws ParseException { String location = null;//from www.j a v a 2 s . c om DateFormat formatter = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss", Locale.US); formatter.setTimeZone(TimeZone.getTimeZone("America/New_York")); Date StartTime = formatter.parse(date); Log.e("n", String.valueOf(StartTime.getTime())); Intent calint = new Intent(Intent.ACTION_INSERT); calint.setType("vnd.android.cursor.item/event"); calint.putExtra("title", name); calint.putExtra("description", description); calint.putExtra("beginTime", StartTime.getTime()); //calint.putExtra(Events.EVENT_TIMEZONE, "America/New_York"); if (description.contains("at")) { location = description.substring(description.lastIndexOf("at") + 3, description.length()); calint.putExtra("eventLocation", location); } startActivity(calint); }
From source file:fr.simon.marquis.secretcodes.ui.MainActivity.java
private void sendEmail(ArrayList<SecretCode> secretCodes) { Intent i = new Intent(Intent.ACTION_SEND); i.setType("message/rfc822"); i.putExtra(Intent.EXTRA_EMAIL, new String[] { getString(R.string.extra_email) }); i.putExtra(Intent.EXTRA_SUBJECT, getString(R.string.extra_subject)); i.putExtra(Intent.EXTRA_TEXT, generateEmailBody(secretCodes)); i.putExtra(Intent.EXTRA_STREAM, ExportContentProvider.CONTENT_URI); startActivity(Intent.createChooser(i, null)); }
From source file:com.ckchan.assignment1.ckchan_todolist.MainActivity.java
@Override //Selecting action bar items public boolean onOptionsItemSelected(MenuItem item) { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. int id = item.getItemId(); if (id == R.id.action_settings) { Settings();//from ww w.j av a2 s .c o m return true; } //Handle presses on the action bar items switch (item.getItemId()) { case R.id.summary_info: SummaryInfo(); return true; case R.id.email_all: try { Context context = getApplicationContext(); TaskDatabase taskDatabase = new TaskDatabase(); ; Email email = taskDatabase.loadEmailAddress(context); ArrayList<TodoTask> taskArray = (ArrayList<TodoTask>) taskDatabase.loadTaskData(context); ArrayList<TodoTask> archiveArray = (ArrayList<TodoTask>) taskDatabase.loadArchiveData(context); //StringBuilder code from: //http://stackoverflow.com/questions/12899953/in-java-how-to-append-a-string-more-efficiently StringBuilder stringBuilder = new StringBuilder(); if (email != null) { Intent i = new Intent(Intent.ACTION_SEND); i.setType("message/rfc822"); i.putExtra(Intent.EXTRA_EMAIL, new String[] { email.getAddress() }); i.putExtra(Intent.EXTRA_SUBJECT, "Todo and Archive Tasks"); stringBuilder.append("Todo Tasks\n"); for (TodoTask task : taskArray) { stringBuilder.append(task.getTaskDescription() + "\n"); } stringBuilder.append("Archive Tasks\n"); for (TodoTask task : archiveArray) { stringBuilder.append(task.getTaskDescription() + "\n"); } String emailContent = stringBuilder.toString(); i.putExtra(Intent.EXTRA_TEXT, emailContent); try { startActivity(Intent.createChooser(i, "Send mail...")); } catch (android.content.ActivityNotFoundException ex) { Toast.makeText(context, "There are no email clients installed.", Toast.LENGTH_SHORT).show(); } } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } default: return super.onOptionsItemSelected(item); } }
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)); }/*from w w w . j ava 2 s . c o 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:org.mrquiz.android.tinyurl.SendTinyUrlActivity.java
private void send() { Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); Intent originalIntent = getIntent(); if (Intent.ACTION_SEND.equals(originalIntent.getAction())) { // Copy extras from the original intent because they miht contain // additional information about the URL (e.g., the title of a // YouTube video). Do this before setting Intent.EXTRA_TEXT to avoid // overwriting the TinyShare. intent.putExtras(originalIntent.getExtras()); }/*from ww w .j av a 2 s.c om*/ intent.putExtra(Intent.EXTRA_TEXT, mTinyUrl); try { CharSequence template = getText(R.string.title_send); String title = String.format(String.valueOf(template), mTinyUrl); startActivity(Intent.createChooser(intent, title)); } catch (ActivityNotFoundException e) { handleError(e); } }
From source file:foam.jellyfish.StarwispBuilder.java
public static void email(Context context, String emailTo, String emailCC, String subject, String emailText, List<String> filePaths) { //need to "send multiple" to get more than one attachment final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE); emailIntent.setType("text/plain"); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { emailTo }); emailIntent.putExtra(android.content.Intent.EXTRA_CC, new String[] { emailCC }); emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject); ArrayList<String> extra_text = new ArrayList<String>(); extra_text.add(emailText);/* w ww . jav a 2 s . c o m*/ emailIntent.putStringArrayListExtra(Intent.EXTRA_TEXT, extra_text); //emailIntent.putExtra(Intent.EXTRA_TEXT, emailText); //has to be an ArrayList ArrayList<Uri> uris = new ArrayList<Uri>(); //convert from paths to Android friendly Parcelable Uri's for (String file : filePaths) { File fileIn = new File(file); Uri u = Uri.fromFile(fileIn); uris.add(u); } emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris); context.startActivity(Intent.createChooser(emailIntent, "Send mail...")); }
From source file:me.kartikarora.transfersh.activities.TransferActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_transfer); mNoFilesTextView = (TextView) findViewById(R.id.no_files_text_view); mFileItemsGridView = (GridView) findViewById(R.id.file_grid_view); FloatingActionButton uploadFileButton = (FloatingActionButton) findViewById(R.id.upload_file_fab); mCoordinatorLayout = (CoordinatorLayout) findViewById(R.id.coordinator_layout); mAdView = (AdView) findViewById(R.id.banner_ad_view); if (uploadFileButton != null) { uploadFileButton.setOnClickListener(new View.OnClickListener() { @Override/*from ww w.j a v a2s . co m*/ public void onClick(View v) { Intent intent = new Intent(Intent.ACTION_OPEN_DOCUMENT); intent.setType("*/*"); startActivityForResult(intent, FILE_RESULT_CODE); } }); } getSupportLoaderManager().initLoader(BuildConfig.VERSION_CODE, null, this); TransferApplication application = (TransferApplication) getApplication(); mTracker = application.getDefaultTracker(); mTracker.send(new HitBuilders.EventBuilder().setCategory("Activity : " + this.getClass().getSimpleName()) .setAction("Launched").build()); }
From source file:fr.bde_eseo.eseomega.events.EventItem.java
public Intent toCalendarIntent() { Intent calIntent = new Intent(Intent.ACTION_INSERT); calIntent.setType("vnd.android.cursor.item/event"); calIntent.putExtra(CalendarContract.Events.TITLE, name); calIntent.putExtra(CalendarContract.Events.EVENT_LOCATION, (lieu != null ? lieu : "")); calIntent.putExtra(CalendarContract.Events.DESCRIPTION, (details != null ? details : "")); SimpleDateFormat sdf = new SimpleDateFormat("HH'h'mm", Locale.FRANCE); String sDate = sdf.format(this.date); boolean allDay = sDate.equals(HOUR_PASS_ALLDAY); calIntent.putExtra(CalendarContract.EXTRA_EVENT_ALL_DAY, allDay); calIntent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, cal.getTimeInMillis()); if (!allDay)/*w w w . ja v a 2 s . c om*/ calIntent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, calFin.getTimeInMillis()); return calIntent; }
From source file:com.digitalarx.android.files.FileOperationsHelper.java
public void sendDownloadedFile(OCFile file) { if (file != null) { Intent sendIntent = new Intent(android.content.Intent.ACTION_SEND); // set MimeType sendIntent.setType(file.getMimetype()); sendIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + file.getStoragePath())); sendIntent.putExtra(Intent.ACTION_SEND, true); // Send Action // Show dialog, without the own app String[] packagesToExclude = new String[] { mFileActivity.getPackageName() }; DialogFragment chooserDialog = ShareLinkToDialog.newInstance(sendIntent, packagesToExclude, file); chooserDialog.show(mFileActivity.getSupportFragmentManager(), FTAG_CHOOSER_DIALOG); } else {//from ww w. ja v a 2 s . com Log_OC.wtf(TAG, "Trying to send a NULL OCFile"); } }
From source file:gov.whitehouse.ui.fragments.app.ArticleViewerFragment.java
@Override public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) { super.onCreateOptionsMenu(menu, inflater); ActionBar actionBar = getSherlockActivity().getSupportActionBar(); if (!((BaseActivity) getSherlockActivity()).isMultipaned()) { actionBar.setHomeButtonEnabled(true); actionBar.setDisplayShowHomeEnabled(false); actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayShowTitleEnabled(true); actionBar.setDisplayUseLogoEnabled(false); }/* w w w . j a v a2 s .c o m*/ MenuItem shareItem = menu.findItem(R.id.menu_share); shareItem.setVisible(true); Intent shareIntent; try { shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/plain"); shareIntent.putExtra(Intent.EXTRA_TEXT, mPageInfo.getString("url")); ShareActionProvider sap = (ShareActionProvider) shareItem.getActionProvider(); sap.setShareHistoryFileName(ShareActionProvider.DEFAULT_SHARE_HISTORY_FILE_NAME); sap.setShareIntent(shareIntent); } catch (JSONException e) { e.printStackTrace(); } MenuItem favoriteItem = menu.findItem(R.id.menu_favorite); favoriteItem.setVisible(true); if (mFavorited) { favoriteItem.setTitle(R.string.unfavorite); favoriteItem.setIcon(R.drawable.ic_favorite); } else { favoriteItem.setTitle(R.string.favorite); favoriteItem.setIcon(R.drawable.ic_unfavorite); } }