我的应用程序内部有视频链接,然后单击共享按钮上的video_player活动,单击要在其内部应用程序中播放视频的视频,我想将该视频共享给WhatsApp或其他社交应用程序
url = getIntent().getStringExtra("live_video_url");
Log.e("url" , "-->"+url);
Intent shareIntent = new Intent ( );
shareIntent.setAction ( Intent.ACTION_SEND ); // temp permission for receiving app to read this file
shareIntent.setType ( "text/plain" );
shareIntent.setFlags ( Intent.FLAG_ACTIVITY_CLEAR_TOP );
shareIntent.putExtra ( Intent.EXTRA_TEXT, "https://com.careerguide"+url );
startActivity ( Intent.createChooser ( shareIntent, "Choose an app" ) );
答案 0 :(得分:0)
我从您的问题中了解到您具有视频链接,并且希望通过您的应用程序将其共享给Whatsapp。 如果正确,请尝试以下代码:
url = getIntent().getStringExtra("live_video_url"); //get URL of your video
Intent share = new Intent(Intent.ACTION_SEND);
share.setType("text/plain");
share.setPackage("com.whatsapp");
share.putExtra(Intent.EXTRA_TEXT , "https://com.careerguide"+url); // Your link here
try {
startActivity(share);
} catch (android.content.ActivityNotFoundException ex) {
Toast.makeText(this , "Whatsapp isn't installed on your device!" , Toast.LENGTH_LONG).show();
}
我希望它能与您合作。