I'm new to developing, for my first app I'm trying to make a web browser. My problem is I cant get my webview to load a url from a shared Intent. All I get is a blank page. I've spent days searching the web, any help would be greatly appreciated. Thank you in advance!
my code to get the intent (in oncreate and onresume)
Intent receivedIntent = getIntent();
String receivedAction = receivedIntent.getAction();
String receivedType = receivedIntent.getType();
try {
if (receivedAction.equals(Intent.ACTION_VIEW)) {
String receivedText = receivedIntent.getStringExtra(Intent.EXTRA_TEXT);
if (receivedText != null) {
if (receivedType.equals("text/plain")) {
webView.loadUrl(receivedText);
}
}
my 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.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="http" />
<data android:scheme="https" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:mimeType="text/plain" />
</intent-filter>
</activity>
you can do something like this
Now on the
Activity
you must get the url withgetDataString()
and on the manifest