Sergio Viudes
Sergio Viudes

Reputation: 2854

Opening URL containing a # from an Android Activity

I'm trying to open a URL containing a #, using this:

startActivity(new Intent("android.intent.action.VIEW", Uri.parse(url)));

But when browser opens, the # is ignored... I don't know why???

Upvotes: 1

Views: 71

Answers (1)

Dayerman
Dayerman

Reputation: 4003

Try to construct the URL properly using URL class URL encoding in Android

String urlStr = "http://abc.dev.domain.com/0007AC/ads/800x480 15sec h.264.mp4";
URL url = new URL(urlStr);
URI uri = new URI(url.getProtocol(), url.getUserInfo(), url.getHost(), url.getPort(), url.getPath(), url.getQuery(), url.getRef());
url = uri.toURL();

Upvotes: 1

Related Questions