0

我正在开发一个 android 应用程序
在单击 listView 项目时它在代码中给出错误

intent = YouTubeIntents.createPlayVideoIntentWithOptions(this," _y5fV27H28Q", true, false);
 tartActivity(intent);

请帮助提前谢谢

MainActivity.java

package com.bollywoodmovies;


import android.os.Bundle;


import com.google.android.youtube.player.YouTubeIntents;
import com.bollywoodmovies.MainActivity;
import com.bollywoodmovies.R;

import android.app.ListActivity;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.CheckedTextView;
import android.widget.ListView;
import android.widget.Toast;
import android.app.Activity;
import android.view.Menu;



public class MainActivity extends ListActivity {

    final int Aatma = 0; //should be equal to the index in your array.
    final int Special26 = 1;
    final int Dabangg2 = 2;
//  intentItems.add(new IntentItem("HollyWood Movies", Aatma));


    String menu[] = {"Aatma","Special26","Dabangg2" };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        //ListView l = (ListView)findViewById(R.id.list);
        setListAdapter(new ArrayAdapter<String>(MainActivity.this,android.R.layout.simple_list_item_1,menu));
    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.activity_main, menu);
        return true;
    }
    protected void onListItemClick(ListView l, View v, int position, long id) {

     /* CheckedTextView selectedItem = (CheckedTextView) v;
       boolean isChecked = selectedItem.isChecked();
       Log.e("TAG","item clicked position = " + position + " isChecked = " + isChecked);
**/
        Intent intent;
        switch (position) {
        case Aatma:
          //    Toast.makeText(this, "AAtma !", Toast.LENGTH_LONG).show();
            intent = YouTubeIntents.createPlayVideoIntentWithOptions(this," _y5fV27H28Q", true, false);
            startActivity(intent);
           break;
        case Special26:
            Toast.makeText(this, "Special26 !", Toast.LENGTH_LONG).show();

            break;

        case Dabangg2:
            Toast.makeText(this, "Dabangg 2 !", Toast.LENGTH_LONG).show();

            break;
        default:
            break;
        }

    }

}

错误日志:

04-30 13:38:30.773: W/dalvikvm(908): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
04-30 13:38:30.803: E/AndroidRuntime(908): FATAL EXCEPTION: main
04-30 13:38:30.803: E/AndroidRuntime(908): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=http://www.youtube.com/watch?v= _y5fV27H28Q pkg=com.google.android.youtube (has extras) }
04-30 13:38:30.803: E/AndroidRuntime(908):  at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1622)
04-30 13:38:30.803: E/AndroidRuntime(908):  at android.app.Instrumentation.execStartActivity(Instrumentation.java:1417)
04-30 13:38:30.803: E/AndroidRuntime(908):  at android.app.Activity.startActivityForResult(Activity.java:3370)
04-30 13:38:30.803: E/AndroidRuntime(908):  at android.app.Activity.startActivityForResult(Activity.java:3331)
04-30 13:38:30.803: E/AndroidRuntime(908):  at android.app.Activity.startActivity(Activity.java:3566)
04-30 13:38:30.803: E/AndroidRuntime(908):  at android.app.Activity.startActivity(Activity.java:3534)
04-30 13:38:30.803: E/AndroidRuntime(908):  at com.bollywoodmovies.MainActivity.onListItemClick(MainActivity.java:61)
04-30 13:38:30.803: E/AndroidRuntime(908):  at android.app.ListActivity$2.onItemClick(ListActivity.java:319)
04-30 13:38:30.803: E/AndroidRuntime(908):  at android.widget.AdapterView.performItemClick(AdapterView.java:298)
04-30 13:38:30.803: E/AndroidRuntime(908):  at android.widget.AbsListView.performItemClick(AbsListView.java:1100)
04-30 13:38:30.803: E/AndroidRuntime(908):  at android.widget.AbsListView$PerformClick.run(AbsListView.java:2749)
04-30 13:38:30.803: E/AndroidRuntime(908):  at android.widget.AbsListView$1.run(AbsListView.java:3423)
04-30 13:38:30.803: E/AndroidRuntime(908):  at android.os.Handler.handleCallback(Handler.java:725)
04-30 13:38:30.803: E/AndroidRuntime(908):  at android.os.Handler.dispatchMessage(Handler.java:92)
04-30 13:38:30.803: E/AndroidRuntime(908):  at android.os.Looper.loop(Looper.java:137)
04-30 13:38:30.803: E/AndroidRuntime(908):  at android.app.ActivityThread.main(ActivityThread.java:5041)
04-30 13:38:30.803: E/AndroidRuntime(908):  at java.lang.reflect.Method.invokeNative(Native Method)
04-30 13:38:30.803: E/AndroidRuntime(908):  at java.lang.reflect.Method.invoke(Method.java:511)
04-30 13:38:30.803: E/AndroidRuntime(908):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
04-30 13:38:30.803: E/AndroidRuntime(908):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
04-30 13:38:30.803: E/AndroidRuntime(908):  at dalvik.system.NativeStart.main(Native Method)
04-30 13:41:06.463: I/Process(908): Sending signal. PID: 908 SIG: 9
4

1 回答 1

0

检查此链接。我相信它肯定会帮助你:

Android 意图:带有菜单和子菜单的列表视图

并且还要检查

如何强制视频在 youtube 播放器中全屏播放?. 希望这会帮助你。如果确实如此。请告诉我。

你也可以通过这个链接。

https://developers.google.com/youtube/android/player/reference/com/google/android/youtube/player/YouTubeIntents

于 2013-04-30T13:54:11.007 回答