得到和分享网页的URL - webView android

问题描述:

我想得到我的webView中当前页面的URL和分享吧。 以下是获取页面URL和共享包名称的代码;我不知道如何一起使用它们。得到和分享网页的URL - webView android

获取页面URL-

String url = webView.getUrl(); 
    if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) { 
     android.text.ClipboardManager clipboard = (android.text.ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); 
     clipboard.setText(url); 
    } else { 
     android.content.ClipboardManager clipboard = (android.content.ClipboardManager) getSystemService(Context.CLIPBOARD_SERVICE); 
     android.content.ClipData clip = android.content.ClipData 
       .newPlainText("text label", url); 
     clipboard.setPrimaryClip(clip); 
    } 

份额软件包名称

findViewById(R.id.exitdlg).setVisibility(View.GONE); 
    Intent shareIntent = new Intent(Intent.ACTION_SEND); 
    shareIntent.setType("text/plain"); 
    shareIntent.putExtra(Intent.EXTRA_TEXT, 
      "http://play.google.com/store/apps/details?id=" 
        + "com.air.blahblah"); 
    startActivity(Intent.createChooser(shareIntent, "Share...")); 

我是新到Android,任何帮助将不胜感激。

你所得到的网址与下面的代码:

String url = webView.getUrl(); 

因此,使用相同的URL在共享意向如下:

findViewById(R.id.exitdlg).setVisibility(View.GONE); 
Intent shareIntent = new Intent(Intent.ACTION_SEND); 
shareIntent.setType("text/plain"); 
shareIntent.putExtra(Intent.EXTRA_TEXT,url); // your above url 
startActivity(Intent.createChooser(shareIntent, "Share...")); 

希望我回答你的问题。