使用Intent Share-Android无法使用锚标记

时间:2017-08-24 05:09:27

标签: android android-intent hyperlink intentfilter

我想使用intents.below分享文本,图片与Gmail,Facebook,Twitter等可点击链接。我的代码但是它不起作用。我也在String资源文件中放入了链接文本,但是不起作用。共享功能应该如此,但是当在Gmail,Facebook,Twitter等中共享时,链接被忽略,Gmail或推文只显示这样的纯文本

private void share(Uri bmpUri)
{
    String hyperlink_url="https://www.google.co.in/?gfe_rd=cr&ei=_3edWb68K4rT8gfx_pCoDw";

    String text = "here";
    String body = "<a href=\"" + hyperlink_url + "\">Click</a>";      
    final Intent shareIntent = new Intent(Intent.ACTION_SEND);   
    shareIntent.putExtra(Intent.EXTRA_TEXT, "Hey! I just saw ABC is having XYZ through the my App! We should check it out."+ "\n" + Html.fromHtml(body));
    shareIntent.setType("text/html");
    shareIntent.putExtra(Intent.EXTRA_SUBJECT, "");
    //String[] mimetypes = {"image/*", "video/*","text/html"}; 
    // shareIntent.putExtra(Intent.EXTRA_MIME_TYPES, mimetypes); 

    final List<ResolveInfo> activities = getPackageManager().queryIntentActivities(shareIntent, 0);

    List<String> appNames = new ArrayList<String>();
    for (ResolveInfo info : activities) {
        appNames.add(info.loadLabel(getPackageManager()).toString());
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Complete Action using...");
    builder.setItems(appNames.toArray(new CharSequence[appNames.size()]), new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int item) {
            ResolveInfo info = activities.get(item);
            if (info.activityInfo.packageName.equals("com.facebook.katana")) {
                // Facebook was chosen
               // shareToFacebook();
            } else if (info.activityInfo.packageName.equals("com.twitter.android")) {
                // Twitter was chosen
                shareIntent.setPackage(info.activityInfo.packageName);
                startActivity(shareIntent);
            } else {
                // start the selected activity
                shareIntent.setPackage(info.activityInfo.packageName);
                startActivity(shareIntent);
            }
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
}

0 个答案:

没有答案