Hello dear StackOverflow community!!! While developing my recent application project i found some problems while debugging the app. In my project i want to pass one data element through 2 activities. Everything looks good (no errors or other stuff) until i choose WatchingActivity in my app. It displays no webview but only white blank space while there should be video choosen in PartActivity. Please help!!!!
public class MainActivity extends AppCompatActivity {
String clipname;
ImageView ka;
ImageView jb;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
ka = (ImageView) findViewById(R.id.imageView1);
jb = (ImageView) findViewById(R.id.imageView2);
}
public void imageView1Clicked(View view) {
// method that is signed in layout file to be called by clicking on imageView1
clipname="Kendra's Adventure";
Intent mainintent = new Intent(this, ChooseAPartActivity.class);
mainintent.putExtra("CLIP", clipname);
startActivity(mainintent);
}
public void imageView2Clicked(View view) {
clipname="Johhny Big";
Intent mainintent = new Intent(this, ChooseAPartActivity.class);
mainintent.putExtra("CLIP", clipname);
startActivity(mainintent);
}
}
public class ChooseAPartActivity extends AppCompatActivity {
TextView title;
TextView part1;
TextView part2;
TextView part3;
TextView part4;
TextView part5;
TextView part6;
String videoname;
String partnumber;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_choose_a_part);
title.findViewById(R.id.textView);
title.findViewById(R.id.textView);
Intent mainintent = getIntent();
String clipname = mainintent.getStringExtra("CLIP");
title.setText(clipname);
videoname = clipname;
}
public void partone (View view) {
//method assigned to textview in layout file
partnumber = "one";
Intent partintent = new Intent(this, WatchingActivity.class);
partintent.putExtra("PART", videoname);
partintent.putExtra("NUMBER", partnumber);
startActivity(partintent);
}
public void parttwo (View view) {
partnumber = "two";
Intent partintent = new Intent(this, WatchingActivity.class);
partintent.putExtra("PART", videoname);
partintent.putExtra("NUMBER", partnumber);
startActivity(partintent);
}
public void partthree (View view) {
partnumber = "three";
Intent partintent = new Intent(this, WatchingActivity.class);
partintent.putExtra("PART", videoname);
partintent.putExtra("NUMBER", partnumber);
startActivity(partintent);
}
public void partfour (View view) {
partnumber = "four";
Intent partintent = new Intent(this, WatchingActivity.class);
partintent.putExtra("PART", videoname);
partintent.putExtra("NUMBER", partnumber);
startActivity(partintent);
}
public void partfive (View view) {
partnumber = "five";
Intent partintent = new Intent(this, WatchingActivity.class);
partintent.putExtra("PART", videoname);
partintent.putExtra("NUMBER", partnumber);
startActivity(partintent);
}
public void partsix (View view) {
partnumber = "six";
Intent partintent = new Intent(this, WatchingActivity.class);
partintent.putExtra("PART", videoname);
partintent.putExtra("NUMBER", partnumber);
startActivity(partintent);
}
}
public class WatchingActivity extends AppCompatActivity {
String clipkey;
WebView screen;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_watching);
Intent sceneintent = getIntent();
String videoname = partintent.getStringExtra("PART");
String partnumber = sceneintent.getStringExtra("NUMBER");
if(videoname == "Kendra's Adventure"){
if(partnumber == "one"){
clipkey = "<iframe width=\"95%\" height=\"95%\" src=\"links work fine i tried it many times so its not that\" frameborder=\"0\" allowfullscreen></iframe>";
}
}
else if(videoname == "Johnny Big"){
if(partnumber == "one") {
clipkey = "<iframe width=\"95%\" height=\"95%\" src=\"\" frameborder=\"0\" allowfullscreen></iframe>";
}
else if(partnumber == "two"){
clipkey = "<iframe width=\"95%\" height=\"95%\" src=\"\" frameborder=\"0\" allowfullscreen></iframe>";
}
}
screen=(WebView)findViewById(R.id.webView);
screen.getSettings().setJavaScriptEnabled(true);
String myvideokey = clipkey;
screen.loadData(myvideokey, "text/html", "utf-8");
screen.setWebChromeClient(new WebChromeClient(){
});
}
}