开发者

Android HttpURLConnection cannot redirect to "market://details?id=my.package.name"

I am launching a HttpURLConnection from my Android device that points my server i.e. http://example.com/download-app. The server receives this request and issues a redirect to market://details?id=my.package.name. The aim is to have the Android Market app on th开发者_StackOverflow中文版e phone open and navigate to the app download page.

However, this doesn't seem to work. I set redirects to true on the HttpURLConnection i.e.

HttpURLConnection.setFollowRedirects(true);

but the URL I receive back is always the same URL to my server i.e. http://example.com/download-app.

If I use a redirect link using the "http" protocol like http://market.android.com/details?id=my.package.name, it works but instead opens up the new web based market NOT the app on the phone.

Has anyone else experienced this?


If you you to direct to the market use the market url.

final Intent marketIntent = new Intent(android.content.Intent.ACTION_VIEW,
     Uri.parse(http://market.android.com/details?id=my.package.name));
startActivity(marketIntent);

This should open the Market app on a phone.


The aim is to have the Android Market app on the phone open and navigate to the app download page.

Then why are you using HttpUrlConnection?

If you want to view a Web page, use an ACTION_VIEW Intent:

startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://example.com/download-app")));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜