本文介绍了通过URL打开vimeo应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这段代码将我带到浏览器,我有vimeo应用程序,如何将其转到vimeo应用程序?
This code takes me to the browser, I have the vimeo application, how can it go to the vimeo application?
vimeo1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://player.vimeo.com/video/83178705?"));
startActivity(browserIntent);
}
});
已编辑
vimeo1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
try{
Intent browserIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://player.vimeo.com/video/83178705"));
browserIntent.setPackage("com.vimeo.android.videoapp");
startActivity(browserIntent);
}
catch(Exception e){
// App is not Installed
//Navigate to Play Store or display message
}
}
});
推荐答案
尝试此操作,在重定向时设置包名称.
Try this, set package name while Re-directing.
catch块.
try{
Intent browserIntent = new Intent(Intent.ACTION_VIEW,
Uri.parse("http://player.vimeo.com/video/83178705"));
browserIntent.setPackage("com.vimeo.android.videoapp");
startActivity(browserIntent);
}
catch(Exception e){
// App is not Installed
//Navigate to Play Store or display message
}
修改
我已经检查过了,您说的没错.我改成了我的代码.现在它打开了应用程序,但是视频没有运行,我不知道为什么.检查此更新的代码.
I have checked this and you were right its not working. I changed into my code. Now its opening Application but video is not running, I don't know why.Check this updated code.
try{
Intent browserIntent = null;
PackageManager pmi = getPackageManager();
browserIntent = pmi.getLaunchIntentForPackage("com.vimeo.android.videoapp");
browserIntent.setAction(Intent.ACTION_VIEW);
browserIntent.setData(Uri.parse("http://player.vimeo.com/video/83178705"));
startActivity(browserIntent);
}
catch(Exception e){
// App is not Installed
//Navigate to Play Store or display message
Toast.makeText(MainActivity.this, "In Catch Block", Toast.LENGTH_SHORT).show();
}
这篇关于通过URL打开vimeo应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!