android - how to open content shared by other apps? -


i want open links shared apps firefox or youtube in webview. whenever press share button, it launches app, never loads url-

// url browsable intent filter     textview uri = (textview) findviewbyid(r.id.urlfield);     // url     url = getintent().getstringextra(intent.extra_text);     uri data = getintent().getdata();     if (data == null) {         uri.settext("");     } else {         uri.settext(getintent().getdata().tostring());         fadeout();     }     // }      webview = (webview) findviewbyid(r.id.webview);     // load url browsable intent filter if there valid url pasted     if (uri.length() > 0)         webview.loadurl(url);     else         // dont load 

manifest

 <intent-filter>             <action android:name="android.intent.action.main" />              <category android:name="android.intent.category.launcher" />         </intent-filter>         <intent-filter>             <action android:name="android.intent.action.send" />              <category android:name="android.intent.category.default" />              <data android:mimetype="text/plain" />             <data android:mimetype="image/*" />         </intent-filter> 

sorry, misinterpret question. thought you're trying open text link being shared app. way, have tried reproduce issue , solution.

manifest:

<activity android:name=".mainactivity">         <intent-filter>             <action android:name="android.intent.action.main" />             <category android:name="android.intent.category.launcher" />         </intent-filter>         <intent-filter>             <action android:name="android.intent.action.send" />             <category android:name="android.intent.category.default"/>             <data android:mimetype="text/plain"/>         </intent-filter>     </activity> 

and here activity

public class mainactivity extends appcompatactivity {  private webview webview; private string url;  @override protected void oncreate(bundle savedinstancestate) {     super.oncreate(savedinstancestate);     setcontentview(r.layout.activity_main);      initview();      intent intent = getintent();     string action = intent.getaction();      if (intent.action_send.equals(action)) {         url = getintent().getstringextra(intent.extra_text);     } }  private void initview(){     webview = (webview)findviewbyid(r.id.webview);      //add enable video streaming (youtube etc.)      //or handle webpage javascript     webview.setwebviewclient(new webviewclient());     webview.setwebchromeclient(new webchromeclient());     webview.getsettings().setjavascriptenabled(true); }  @override protected void onpostcreate(@nullable bundle savedinstancestate) {     super.onpostcreate(savedinstancestate);      if(null != url) {         log.i("url", url);         webview.loadurl(url);     } } 

please let me know if not working.


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -