2 回答

TA貢獻(xiàn)1898條經(jīng)驗(yàn) 獲得超8個(gè)贊
您可以使用具有特定結(jié)構(gòu)的深層鏈接
追加吹線清單
定義 ACTION_VIEW 意圖操作,以便可以從 Google 搜索訪問(wèn)意圖過(guò)濾器
<action android:name="android.intent.action.VIEW" />
并添加 BROWSABLE 類(lèi)別以便可以從 out off app 訪問(wèn)
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
添加您的鏈接結(jié)構(gòu)
<data android:host="youtube" android:pathPattern=".*" android:scheme="https"/>
有意獲取數(shù)據(jù)
Intent intent = getIntent();
Uri data = intent.getData();
發(fā)送數(shù)據(jù)到應(yīng)用程序
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://youtube"));
startActivity(launchIntent);

TA貢獻(xiàn)1810條經(jīng)驗(yàn) 獲得超4個(gè)贊
您需要使 String title 和 urlYoutube 全局化(即在 onCreate 之外)。然后通過(guò)這種方式在 onCreate 內(nèi)部初始化,您可以在 onCreate 方法之外使用意圖數(shù)據(jù)
例如
public class PlayerActivity extends AppCompatActivity {
SimpleExoPlayerView simpleExoPlayerView;
private String GRID_YOUTUBE_ID = "s9-Id1WJQyo";
private String BASE_URL = "https://www.youtube.com";
private String youtubeLink = BASE_URL + "/watch?v=" + GRID_YOUTUBE_ID;
public String title,urlYoutube;
//hello
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_player);
extractYoutubeUrl();
simpleExoPlayerView = findViewById(R.id.player);
title = getIntent().getExtras().getString("title");
urlYoutube = getIntent().getExtras().getString("videourl");
}
我希望這能解決你的問(wèn)題。
添加回答
舉報(bào)