所以在我的片段中,我放置了以下代码来处理我的列表视图的 onclickitem
ls.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
ChannelItem c = (ChannelItem) parent.getAdapter().getItem(position);
Intent myIntent = new Intent(getActivity().getBaseContext(), PlayerViewActivity.class);
myIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
getActivity().getBaseContext().startActivity(myIntent);
}
});
我知道这不是最干净的代码,我正计划重新编写它。但它暂时有效(我在使用 YoutubeBaseActivity 之前通过测试活动对其进行了测试)。只是为了澄清这段代码没有问题,但它是为了说明我正在遵循的流程。
因此,当 youtube 活动开始时,它会执行以下课程
public class PlayerViewActivity extends YouTubeBaseActivity implements
YouTubePlayer.OnInitializedListener {
static private final String VIDEO = "4SK0cUNMnMM";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.youtube_player);
YouTubePlayerView youTubeView = (YouTubePlayerView)
findViewById(R.id.youtube_view);
youTubeView.initialize(Api.DEV_KEY, this);
}
@Override
public void onInitializationFailure(YouTubePlayer.Provider provider,
YouTubeInitializationResult error) {
Toast.makeText(this, "Oh no! "+error.toString(),
Toast.LENGTH_LONG).show();
}
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer player,
boolean wasRestored) {
player.loadVideo(VIDEO);
}
}
这是我在任何地方都找不到任何帮助的地方
youTubeView.initialize(Api.DEV_KEY, this);
这行代码一遍又一遍地抛出同样的错误
Caused by: java.lang.IllegalArgumentException: callingAppVersion cannot be null or empty
at com.google.android.youtube.player.internal.ac.a(Unknown Source)
at com.google.android.youtube.player.internal.o.<init>(Unknown Source)
at com.google.android.youtube.player.internal.ad.a(Unknown Source)
at com.google.android.youtube.player.YouTubePlayerView.a(Unknown Source)
at com.google.android.youtube.player.YouTubeBaseActivity$a.a(Unknown Source)
at com.google.android.youtube.player.YouTubePlayerView.initialize(Unknown Source)
at view.PlayerViewActivity.onCreate(PlayerViewActivity.java:44)
at android.app.Activity.performCreate(Activity.java:5104)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
... 11 more
谁能帮我?