จะเปิดแอปพลิเคชั่น Youtube เพื่อเปิดช่องได้อย่างไร?

ฉันต้องการเข้าถึงจากแอปพลิเคชันของฉันไปยัง youtube เพื่อเปิดช่อง ฉันค้นหาวิธีแก้ปัญหาแล้ว แต่ฉันเพิ่งพบวิธีเปิด/สตรีมวิดีโอ:

Intent i = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube:VIDEO_ID"));
startActivity(i);

แต่แล้วการเปิดช่องโดยตรงล่ะ?

ขอบคุณมาก.


person androniennn    schedule 25.02.2012    source แหล่งที่มา


คำตอบ (3)


Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(urlStr));
startActivity(intent);

หากคุณใช้ URL ของช่อง YouTube เช่น: http://www.youtube.com/user/JustinBieberVEVO

นี่ควรให้ตัวเลือกแก่คุณในการเปิด youtube ไปยังช่องที่ระบุ

หวังว่านี่จะช่วยได้!

person ByteMe    schedule 25.02.2012
comment
ฉันหวังว่าลิงก์จะไม่ใช่ beiber จริงๆ แต่เป็นอะไรบางอย่าง อย่างอื่นจริงๆ โอ้ดี. ขอบคุณสำหรับคำแนะนำเจตนา - person Silas Greenback; 15.03.2013

ฉันรู้ว่าคำตอบนี้ช้า แต่ฉันก็อยากจะแบ่งปันเรื่องนี้ต่อไป สิ่งนี้ได้ผลสำหรับฉัน:

vnd.youtube://user/channel/channel_id

ซึ่งจะเป็นการเปิดช่องโดยตรงในแอป YouTube โดยไม่ต้องถามผู้ใช้

อัปเดต

ไม่ได้ใส่โค้ดใดๆ เนื่องจากฉันใช้ React Native และบางทีผู้คนอาจกำลังมองหาโค้ดเนทิฟอยู่ อย่างไรก็ตามคุณไปที่นี่:

Linking
    .openURL( 'vnd.youtube://user/channel/' + channel_id )
    .catch( ... )

แต่ ฉันคิดว่า ใน โค้ดเนทิฟ มันควรจะเป็นดังนี้:

Intent appIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube://user/channel/" + channel_id));
try {
  context.startActivity(appIntent);
} catch (ActivityNotFoundException ex) { ... }

ฉันไม่คุ้นเคยกับโค้ดเนทีฟมากนัก ดังนั้นมันอาจจะผิด แต่ควรใช้งานได้เหมือนเป็นแนวทาง

person Zenntro    schedule 22.06.2018
comment
คุณควรอธิบายหรือข้อมูลเพิ่มเติมหรือรวมรหัส - person Nicolás Alarcón Rapela; 22.06.2018
comment
@NicolásAlarcónR. หวังว่าจะช่วยได้นิดหน่อย - person Zenntro; 22.06.2018
comment
ดีที่สุด . ทุกอย่างสำเร็จได้ด้วยการฝึกฝน! @marcoaguayo1915 - person Nicolás Alarcón Rapela; 22.06.2018
comment
vnd.youtube://channel/' + channel_id ใช้งานได้สำหรับฉัน (ไม่มี user) - person Sam Chen; 13.01.2021

vnd.youtube://channel/channel_id

สำหรับ URL ที่กำหนดเอง vnd.youtube://c/channel_permalink

person Sutharshan    schedule 05.07.2021