1. Are you ready for the Galaxy S20? Here is everything we know so far!

[moved]

Discussion in 'Android Development' started by aSpoon, Aug 14, 2017.

  1. aSpoon

    aSpoon Lurker
    Thread Starter

    Whenever i run the app i get no errors but the app doesnt open and on my simulator it says "CFBC (the name of my app) Has stoped running here is my code i have 6 activities i know its a lot but if anyone can tell me why its crashing with 0 errors would help a ton

    Code (Java):
    1. package org.cfbcla.cfbc;
    2.  
    3. import android.app.Activity;
    4. import android.content.Intent;
    5. import android.os.Bundle;
    6. import android.view.View;
    7.  
    8. public class MainActivity extends Activity {
    9.  
    10.     @Override
    11.     protected void onCreate(Bundle savedInstanceState) {
    12.         super.onCreate(savedInstanceState);
    13.         setContentView(R.layout.activity_main);
    14.  
    15.     }
    16.  
    17.     public void onButtonClick(View v) {
    18.         if (v.getId() == R.id.A) {
    19.             Intent i = new Intent(MainActivity.this, Display.class);
    20.             startActivity(i);
    21.         }
    22.  
    23.     }
    24.  
    25.     public void onButtonClick2(View v2) {
    26.         if (v2.getId() == R.id.C) {
    27.             Intent i2 = new Intent(MainActivity.this, Display2.class);
    28.             startActivity(i2);
    29.         }
    30.     }
    31.     public void onbuttonClick3(View v3) {
    32.         if (v3.getId() == R.id.S) {
    33.             Intent i3 = new Intent(MainActivity.this, Display3.class);
    34.             startActivity(i3);
    35.         }
    36.     }
    37.     public void onButtonclick4(View v4) {
    38.         if (v4.getId() == R.id.M) {
    39.             Intent i4 = new Intent(MainActivity.this, Display4.class);
    40.             startActivity(i4);
    41.         }
    42.     }
    43.  
    44. }
    Code (Java):
    1. package org.cfbcla.cfbc;
    2.  
    3. import android.app.Activity;
    4. import android.content.Intent;
    5. import android.os.Bundle;
    6. import android.view.View;
    7.  
    8. /**
    9. * Created by kwia on 8/4/17.
    10. */
    11.  
    12. public class Display4 extends Activity{
    13.  
    14.     @Override
    15.     protected void onCreate(Bundle savedInstanceState) {
    16.         super.onCreate(savedInstanceState);
    17.         setContentView(R.layout.display4);
    18.     }
    19.     public void onButtonclick4(View v4) {
    20.         if (v4.getId() == R.id.button4) {
    21.             Intent i4 = new Intent(Display4.this, MainActivity.class);
    22.             startActivity(i4);
    23.         }
    24.     }
    25. }
    26.  
    Code (Java):
    1. package org.cfbcla.cfbc;
    2.  
    3. import android.content.Intent;
    4. import android.os.Bundle;
    5. import android.support.v7.app.AppCompatActivity;
    6. import android.view.View;
    7. import android.widget.Button;
    8.  
    9. import com.google.android.youtube.player.YouTubeInitializationResult;
    10. import com.google.android.youtube.player.YouTubePlayer;
    11. import com.google.android.youtube.player.YouTubePlayerView;
    12.  
    13.  
    14. /**
    15. * Created by kwia on 8/4/17.
    16. */
    17.  
    18. public class Display3 extends AppCompatActivity{
    19.     YouTubePlayerView mYouTubePlayerView;
    20.     Button btnPlay;
    21.     YouTubePlayer.OnInitializedListener mOnInitializedListener;
    22.  
    23.     @Override
    24.     protected void onCreate(Bundle savedInstanceState) {
    25.         super.onCreate(savedInstanceState);
    26.         setContentView(R.layout.display3);
    27.         btnPlay = (Button) findViewById(R.id.btnPlay);
    28.         mYouTubePlayerView = (YouTubePlayerView) findViewById(R.id.youtubePlay);
    29.  
    30.         mOnInitializedListener = new YouTubePlayer.OnInitializedListener() {
    31.             @Override
    32.             public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) {
    33.                 youTubePlayer.loadVideo("sFXQ1vAaKXA");
    34.  
    35.  
    36.  
    37.             }
    38.  
    39.             @Override
    40.             public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) {
    41.  
    42.             }
    43.         };
    44.         btnPlay.setOnClickListener(new View.OnClickListener() {
    45.             @Override
    46.             public void onClick(View view) {
    47.                 mYouTubePlayerView.initialize(YTConfig.getApiKey(), mOnInitializedListener);
    48.  
    49.             }
    50.         });
    51.  
    52.  
    53.  
    54.     }
    55.     public void onButtonclick4(View v4) {
    56.         if (v4.getId() == R.id.button) {
    57.             Intent i4 = new Intent(Display3.this, MainActivity.class);
    58.             startActivity(i4);
    59.         }
    60.     }
    61. }
    62.  
    63.  
    Code (Java):
    1. package org.cfbcla.cfbc;
    2.  
    3. import android.app.Activity;
    4. import android.content.Intent;
    5. import android.os.Bundle;
    6. import android.view.View;
    7.  
    8. /**
    9. * Created by kwia on 8/4/17.
    10. */
    11.  
    12. public class Display2 extends Activity{
    13.  
    14.     @Override
    15.     protected void onCreate(Bundle savedInstanceState) {
    16.         super.onCreate(savedInstanceState);
    17.         setContentView(R.layout.display2);
    18.     }
    19.     public void onButtonclick4(View v4) {
    20.         if (v4.getId() == R.id.button) {
    21.             Intent i4 = new Intent(Display2.this, MainActivity.class);
    22.             startActivity(i4);
    23.         }
    24.     }
    25. }
    26.  
    27.  
    Code (Java):
    1. package org.cfbcla.cfbc;
    2.  
    3.  
    4. import android.content.Intent;
    5. import android.os.Bundle;
    6. import android.support.v7.app.AppCompatActivity;
    7. import android.view.View;
    8. import android.widget.Button;
    9.  
    10. import com.google.android.youtube.player.YouTubeInitializationResult;
    11. import com.google.android.youtube.player.YouTubePlayer;
    12. import com.google.android.youtube.player.YouTubePlayerView;
    13.  
    14. import java.util.ArrayList;
    15. import java.util.List;
    16.  
    17.  
    18. /**
    19. * Created by kwia on 8/4/17.
    20. */
    21.  
    22. public class Display extends AppCompatActivity {
    23.     YouTubePlayerView mYouTubePlayerView;
    24.     Button btnPlay;
    25.     YouTubePlayer.OnInitializedListener mOnInitializedListener;
    26.  
    27.  
    28.  
    29.     @Override
    30.     public void onBackPressed() {
    31.  
    32. }
    33.  
    34.     @Override
    35.     protected void onCreate(Bundle savedInstanceState) {
    36.         super.onCreate(savedInstanceState);
    37.         setContentView(R.layout.display);
    38.         btnPlay = (Button) findViewById(R.id.btnPlay);
    39.         mYouTubePlayerView = (YouTubePlayerView) findViewById(R.id.youtubePlay);
    40.  
    41.         mOnInitializedListener = new YouTubePlayer.OnInitializedListener() {
    42.             @Override
    43.             public void onInitializationSuccess(YouTubePlayer.Provider provider, YouTubePlayer youTubePlayer, boolean b) {
    44.                 List<String> videoList = new ArrayList<>();
    45.                 videoList.add("QOwE0XQei_M");
    46.                 videoList.add("5sTXWESDBB0");
    47.                 youTubePlayer.loadVideos(videoList);
    48.  
    49.  
    50.  
    51.             }
    52.  
    53.             @Override
    54.             public void onInitializationFailure(YouTubePlayer.Provider provider, YouTubeInitializationResult youTubeInitializationResult) {
    55.  
    56.             }
    57.         };
    58.         btnPlay.setOnClickListener(new View.OnClickListener() {
    59.             @Override
    60.             public void onClick(View view) {
    61.                 mYouTubePlayerView.initialize(YTConfig.getApiKey(), mOnInitializedListener);
    62.  
    63.             }
    64.         });
    65.  
    66.  
    67.  
    68.     }
    69.  
    70.  
    71.     public void onButtonclick4(View v4) {
    72.         if (v4.getId() == R.id.button3) {
    73.             Intent i4 = new Intent(Display.this, MainActivity.class);
    74.             startActivity(i4);
    75.         }
    76.     }
    77. }
    78.  
     



    1. Download the Forums for Android™ app!


      Download

       
  2. Deleted User

    Deleted User Guest

    If your app crashed there will be a stack trace in the logcat view. You need to show this to allow someone to help you.
     
  3. aSpoon

    aSpoon Lurker
    Thread Starter

    where do i find it
     
Loading...
Similar Threads - moved
  1. Michael Campbell
    Replies:
    5
    Views:
    475
  2. sargodhianhawk
    Replies:
    2
    Views:
    580
  3. MNH
    Replies:
    12
    Views:
    826
  4. MikadoWu
    Replies:
    9
    Views:
    519
  5. sargan
    Replies:
    7
    Views:
    509
  6. kumaranil13k
    Replies:
    10
    Views:
    1,137
  7. tinker123
    Replies:
    1
    Views:
    666
  8. kumaranil13k
    Replies:
    8
    Views:
    1,167
  9. AMOCO
    Replies:
    3
    Views:
    796
  10. kumaranil13k
    Replies:
    3
    Views:
    777

Share This Page

Loading...