我正在尝试通过代码打开Vine (https://vine.co/)安卓应用程序,进入一个特定的个人资料页面。我一直在尝试通常的方法,通过URI,但没有成功。下面是我当前的非函数代码:
public void vineButtonClicked(View view)
{
Intent vineIntent = getVineIntent(view.getContext(), VINE_PROFILE_ID);
try {
startActivity(vineIntent);
} catch(Exception e) {
// getVineIntent() doesn't fail on returning a new intent with
// the vine:// URI, so this catches the failed intent. Why
// doesn't getVineIntent fail?
Toast.makeText(view.getContext(), "Vine is not installed!", Toast.LENGTH_SHORT).show();
}
}
public Intent getVineIntent(Context context, String userProfile) {
try {
return new Intent(Intent.ACTION_VIEW,
Uri.parse("vine://user/".concat(userProfile)));
} catch (Exception e) {
return getWebViewIntent("http://vine.co");
}
}我尝试用vine://替换成twitter:// URI方案,结果与预期的一样。我怎么才能让它工作呢?
发布于 2013-06-14 02:09:48
为什么getVineIntent不会失败?
为什么会这样呢?您所要做的就是构建一个Intent。
我怎么才能让它工作呢?
在Vine获得一份工作,并在一些应用程序中添加对vine:// Uri values的支持。显然,你没有一个应用程序来响应这样的Uri,我假设你已经在你的设备上安装了一些Vine客户端。
发布于 2014-09-08 18:17:51
这样的代码就可以完成这项工作:
String vineUrl = "https://vine.co/u/<PAGE_ID>";
Intent vineIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(vineUrl));
vineIntent.setPackage("co.vine.android");
try {
startActivity(vineIntent);
} catch (ActivityNotFoundException e) {
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(vineUrl)));
}https://stackoverflow.com/questions/17093837
复制相似问题