Open vimeo application via URL

2019-09-18 22:34发布

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);
            }
        });

EDITED

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                         
                }

            }
        });

3条回答
狗以群分
2楼-- · 2019-09-18 22:54

We actually recently made a vimeo-deeplink-android library which should help you achieve exactly what you're looking to do.

You could include it with gradle:

compile 'com.vimeo.android.deeplink:vimeo-deeplink:1.0.0'

And then deeplink to your video with this method:

boolean handled = VimeoDeeplink.showVideoWithUri(Context context, String videoUri)

Where videoUri is equal to /videos/83178705.

查看更多
仙女界的扛把子
3楼-- · 2019-09-18 23:05

Try this, set package name while Re-directing.

catch block will be called if no app is installed related to that package.

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                         
}

Edit

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();
}
查看更多
你好瞎i
4楼-- · 2019-09-18 23:07

With the official Vimeo app you can do this:

startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://player.vimeo.com/video/83178705")));

While this looks almost identical to your code, aside from lack of a ?, on my Android phone it works fine (opens the Vimeo app).

查看更多
登录 后发表回答