"http" va "?" android veb-pochtasiga mailto havolalarini kesib olishmoqda

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    this.getWindow().requestFeature(Window.FEATURE_PROGRESS);
    setContentView(R.layout.main);

   //Don't create another webview reference here,
   //just use the one you declared at class level.
    webview = (WebView) findViewById(R.id.webview);
    webview.getSettings().setJavaScriptEnabled(true);
    webview.loadUrl("http://www.example.com");

    webview.setWebChromeClient(new WebChromeClient() {
        public void onProgressChanged(WebView view, int progress)
        {
            activity.setTitle("Loading...");
            activity.setProgress(progress * 100);

            if(progress == 100)
                activity.setTitle(R.string.app_name);
        }
    });

    webview.setWebViewClient(new WebViewClient() {
        @Override
        public void onReceivedError(WebView view, int errorCode, String     description, String failingUrl)
        {
       //Handle the error
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url)
        {
          if(url.startsWith("mailto:")){
              MailTo mt = MailTo.parse(url);
              Intent i = newEmailIntent(HelloWorld.this, mt.getBody(), mt.getSubject());
              startActivity(i);
              view.reload();
              return true;
        }

        view.loadUrl(url);
        return true;
    }

   });
}
public static Intent newEmailIntent(Context context, String body, String subject ) {
    Intent intent = new Intent(Intent.ACTION_SEND);
    intent.putExtra(Intent.EXTRA_EMAIL, new String[] {});
    intent.putExtra(Intent.EXTRA_TEXT, body);
    intent.putExtra(Intent.EXTRA_SUBJECT, subject);
    intent.setType("rfc2368/html");
    return intent;
   }
} 

Webview dasturiga mailto qo'shishga urinish. Ilovani ishga tushirganingizda va pochta aloqasini bosganingizda messengerni ochadi. Nima uchun "http" va "?" mailto tomonidan tan olinmagan va kesilmaydi. Xuddi shu mailto havolasi qurilmalarda an'anaviy brauzerda juda yaxshi ishlaydi. Men olishim kerak bo'lgan yagona maydon - mavzu va tana.

0
Siz mailto havolasining qaysi nuqtasida mangalanayotganini aniqlay olasizmi?
qo'shib qo'ydi muallif slayton, manba
Kechirasiz, men aniqroq bo'lishi kerak edi. kodingizda qaysi nuqtada linkni burib olishni bilib olasiz, buni tushunish uchun logcat yordamida ishlatiladigan barcha joylarda URL satrini ko'rsatasiz.
qo'shib qo'ydi muallif slayton, manba
Ema & zwnj; il dan bu misol, mailto xabarining tanasida ko'rsatiladigan yagona narsa "/ exampletype" dan oldin va/yoki boshlanishidan oldinmi? va yo'qolganidan keyin.
qo'shib qo'ydi muallif zef99, manba

1 javoblar

Yaxshi tikish: mailto havolasi mavzusidagi/tarkibidagi joylardagi tarkibning har qanday URL kodi MailTo parolini olish kodiga kirganida URL qochib ketganligiga ishonch hosil qiling (matnning to'g'riligi, ampersand va boshqalar). "? " xususan, Mailto RFC .

Ya'ni, yo'q

mailto://...subject=http://foo.com?x=y

balki o'rniga harakat qilib ko'ring

mailto://...subject=http%3A%2F%2Ffoo.com%3Fx%3Dy
0
qo'shib qo'ydi
To'g'ri url kodirovkasi bilan oldingi pog'onalarni va savollar belgilarini o'zgartirdim va hali ham tanani va mavzuni to'ldirishni istamayman.
qo'shib qo'ydi muallif zef99, manba