Android share html link

Use plain text to allow more apps to catch your Solution 2: You only miss a small change to your code — use to encode the string as HTML. a more detailed example is available at this link: http://blog.iangclifton.com/2010/05/17/sending-html-email-with-android-intent/ This will not allow you to share on Facebook since the Facebook app dows not support with but this will allow you to share HTML content using the Gmail app Solution 3: Share to Facebook (using this method can only share the link) Share to Email (using this method can change the email content to html format, but don’t work using default email client, it works on gmail client.) question. controls whether links such as urls and email addresses are automatically found and converted to clickable links in .

I am trying to share an html link to either facebook, twitter or email. Here is what I have so far, but two things are going wrong.

Intent shareIntent = new Intent(Intent.ACTION_SEND); shareIntent.setType("text/html"); shareIntent.putExtra(Intent.EXTRA_TEXT, "" + htmlUrl + ""); startActivity(Intent.createChooser(shareIntent, "Share!")); 

First this only shows the email application in the list.

Secondly it’s showing up as full text within the email and not as an HTML item.

Your MIME type is wrong. Use this instead:

shareIntent.setType("text/plain"); 

If you just want to share a link and not full-blown HTML, just use the url as the Intent.EXTRA_TEXT value:

shareIntent.putExtra( Intent.EXTRA_TEXT, url ); 

Note that only a few apps (like GMail, Bluetooth and Dropbox) support sharing HTML. Use plain text to allow more apps to catch your Intent

You only miss a small change to your code — use Html.fromHtml to encode the string as HTML.

a more detailed example is available at this link: http://blog.iangclifton.com/2010/05/17/sending-html-email-with-android-intent/

This will not allow you to share on Facebook since the Facebook app dows not support ACTION_SEND with text/html but this will allow you to share HTML content using the Gmail app

Share to Facebook (using this method can only share the link)

Intent facebookIntent = new Intent(Intent.ACTION_SEND); facebookIntent.setType("text/plain"); facebookIntent.setPackage("com.facebook.katana"); facebookIntent.putExtra(Intent.EXTRA_TEXT, shareUrl); startActivity(facebookIntent); 

Share to Email (using this method can change the email content to html format, but don’t work using default email client, it works on gmail client.)

 Intent intent = new Intent(Intent.ACTION_SEND); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra(Intent.EXTRA_SUBJECT, shareTitle); intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(content of your email)); intent.setType("message/rfc822"); startActivity(Intent.createChooser(intent, "Share to Email. ")); 
 Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_TEXT, your content); intent.setType("application/twitter"); startActivity(intent); 
shareIntent.setType("text/html"); 

should do for the html part. Why only the email shows up no idea, do you have other apps like facebook, twitter etc installed to handle share intents?

Читайте также:  Что такое клиентский javascript

following problem: I have got a method that generates the result of some computation and returns this result as a string. Now I would like this result to contain a clickable link. How do I do that?

Here is what I have done so far:

This is part of my method that generates the result string:

Spanned link = Html.fromHtml("Apple.com"); String result = "Website is: " + link; 

Then, in another method that uses the String result I just set the text of the TextView resultText like this:

The problem is that while the text is displayed the text is not a link and hence not clickable. However, I already set this attribute in XML file of the according TextView:

android:linksClickable="true" 

Ok, I figured it out myself with the help of this post on http://android-coding.blogspot.de/2013/04/display-html-string-with-link-on.html

Here is what I did, maybe it is helpful to someone in the future:

I made these changes (compare with them with my code in my question)

    In my result String generating method I put this code:

String link = "Apple.com"; String result = "Website is: " + link; 
android:autoLink="web" android:linksClickable="true" 
resultText.setText(Html.fromHtml(result)); resultText.setMovementMethod(LinkMovementMethod.getInstance()); 

You can cut the string according to ‘ . You can do this trim() or substring() method.Take a look at this link.

See How to make normal links in TextView clickable? question.

android:autoLink=»web» controls whether links such as urls and email addresses are automatically found and converted to clickable links in TextView . Try and see.

In your original code try

declare a string in string.xml:

String link = Html.fromHtml(getResources().getString(R.string.mylinks)); 

Can I make a phone call from HTML on Android?, Yes you can; it works on Android too: tel: phone_number. Calls the entered phone number. Valid telephone numbers as defined in the IETF RFC …

For example: Take a look at the following string resource:

 This link will take you to google.com. More text here. 

Now I want this string resource to look like this in my app:

This link will take you to Google. More text here.

I can’t use three textviews. This was just an example. So I can’t make the entire textview a link.

(Why? What I’m doing in my app is … I have say a dozen buttons, each of them sends a string resource ID as an intent to a «Text Shower Activity» … and in that I simply have a single textview which shows different texts based on which button the user clicked. So, I’m saving on app size.

Plus every such text string resource has different number of links at different places, so it’s not feasible to have a single textview just for links and somehow weave it in between.)

So, I need to make a little bit of the string resource into a link. I’ve tried the thing with no effect.

to go to Googleclick here]]> and this]]> moves you to yahoo! 
yourTextView.setMovementMethod(LinkMovementMethod.getInstance()); yourTextView.setText(Html.fromHtml(getString(R.string.mlink))); 

Note that you need to put your html link inside the CDATA tag, this is the proper way to use links in string resources.

Just to add on @Droidman’s answer if anyone wants to use it without CDATA, Below will also work without CDATA but we have to escaped the characters such as »

to go to Google <a href=\"http://google.com\">click here</a> and <a href=\"http://yahoo.com\">this</a> moves you to yahoo! 
yourTextView.setMovementMethod(LinkMovementMethod.getInstance()); yourTextView.setText(Html.fromHtml(getString(R.string.mlink))); 

Html — Android sms link with a body parameter, If I remove the body parameter on the link it works fine, but I need the body parameter. I’ve tried diffrent formatting of the number including +15553332222 , …

Источник

Use plain text to allow more apps to catch your Solution 2: You only miss a small change to your code — use to encode the string as HTML. a more detailed example is available at this link: http://blog.iangclifton.com/2010/05/17/sending-html-email-with-android-intent/ This will not allow you to share on Facebook since the Facebook app dows not support with but this will allow you to share HTML content using the Gmail app Solution 3: Share to Facebook (using this method can only share the link) Share to Email (using this method can change the email content to html format, but don’t work using default email client, it works on gmail client.) Just use .each iteration and replace the string with desired URL UPDATED ANSWER Working Demo : http://jsfiddle.net/cmzqv/1/ Solution : Use Regexp Working DEMO : http://jsfiddle.net/cmzqv/ Code : Solution 1: If you send text with link like «Here is our link: http://stackoverflow.com» — twitter will understand it and get info from your link and show it — as I understand you need to see your recognized link in twitter feed.

Your MIME type is wrong. Use this instead:

shareIntent.setType("text/plain"); 

If you just want to share a link and not full-blown HTML, just use the url as the Intent.EXTRA_TEXT value:

shareIntent.putExtra( Intent.EXTRA_TEXT, url ); 

Note that only a few apps (like GMail, Bluetooth and Dropbox) support sharing HTML. Use plain text to allow more apps to catch your Intent

You only miss a small change to your code — use Html.fromHtml to encode the string as HTML.

a more detailed example is available at this link: http://blog.iangclifton.com/2010/05/17/sending-html-email-with-android-intent/

This will not allow you to share on Facebook since the Facebook app dows not support ACTION_SEND with text/html but this will allow you to share HTML content using the Gmail app

Share to Facebook (using this method can only share the link)

Intent facebookIntent = new Intent(Intent.ACTION_SEND); facebookIntent.setType("text/plain"); facebookIntent.setPackage("com.facebook.katana"); facebookIntent.putExtra(Intent.EXTRA_TEXT, shareUrl); startActivity(facebookIntent); 

Share to Email (using this method can change the email content to html format, but don’t work using default email client, it works on gmail client.)

 Intent intent = new Intent(Intent.ACTION_SEND); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra(Intent.EXTRA_SUBJECT, shareTitle); intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(content of your email)); intent.setType("message/rfc822"); startActivity(Intent.createChooser(intent, "Share to Email. ")); 
 Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_TEXT, your content); intent.setType("application/twitter"); startActivity(intent); 

How To Add Twitter Card and Open Graph Social, twitter:card: this tag specifies the type of Twitter Card that should be displayed. The summary_large_image type displays a short summary with a large image preview. twitter:site: your Twitter username, or your site or company’s username. twitter:title: the title you’d like used in the card.

The solution is pretty simple.. Just use .each iteration and replace the string with desired URL

UPDATED ANSWER

Working Demo : http://jsfiddle.net/cmzqv/1/

 function(i,html) < return html.replace(/(@\w+)/g, '  Working DEMO : http://jsfiddle.net/cmzqv/  

Sharing a URL with a query string on Twitter, I’m trying to put a Twitter share link in an email. Because this is in an email I can’t rely on JavaScript, and have to use the «Build Your Own» Tweet button. For example, sharing a link to Google: Standard html code for & … Usage examplehttp://twitter.com/share?text=text goes here&url=http://url goes here&hashtags=hashtag1,hashtag2,hashtag3Feedback

If you send text with link like «Here is our link: http://stackoverflow.com» — twitter will understand it and get info from your link and show it — as I understand you need to see your recognized link in twitter feed. To post link you can make intent like @Adrian Sicaru or create your own custom dialog using asynctask with twitter4j as you mention:

@Override protected Bundle doInBackground(Bundle. params) < Bundle args = params[0]; Bundle result = new Bundle(); String paramMessage = args.getString(MESSAGE); String paramLink = args.getString(LINK); ConfigurationBuilder builder = new ConfigurationBuilder(); builder.setOAuthConsumerKey("your ConsumerKey"); builder.setOAuthConsumerSecret("your ConsumerSecret"); String accessToken = "your Token"; String accessTokenSecret = "your Secret"; TwitterFactory factory = new TwitterFactory(builder.build()); mTwitter = factory.getInstance(new AccessToken(accessToken, accessTokenSecret)); try < StatusUpdate status = new StatusUpdate(paramMessage); if (paramLink != null) < status = new StatusUpdate(paramMessage + " " + paramLink); >mTwitter.updateStatus(status); > catch (TwitterException e) < result.putString(RESULT_ERROR, e.getMessage()); >return result; > 

You can do it via intent like this :

Intent sendIntent = new Intent(); sendIntent.setAction(Intent.ACTION_SEND); sendIntent.putExtra(Intent.EXTRA_TEXT, "This is my text to send."); sendIntent.setType("text/plain"); startActivity(sendIntent); 

This will open a list with apps already installed that can answer the intent, like gmail, facebook and. twitter.

You can find more information here: http://developer.android.com/training/sharing/send.html

Also, if you want to directly call twitter and don’t want to choose, have a look at this answer

Like @TribblerWare answered just write link in tweet and twitter recognized it.

By the way, you can use ASNE library for this — just authorize user and use requestPostLink with bundle as parameter

Bundle postParams = new Bundle(); postParams.putString(SocialNetwork.BUNDLE_LINK, link); socialNetwork.requestPostLink(postParams, message, postingComplete); 

more detailed you can see in tutorial

Html share link via twitter Code Example, “html share link via twitter” Code Answer’s. twitter share link html . html by Lokesh003 on Sep 05 2020 Donate Comment Lokesh003 on …

Источник

Оцените статью