[Android Apps and Games] anuben:
trying to attach webview

hello guys i am trying to attach Webview in SimpleWindow in this code

but its not working its getting force close when i run my app, :fingers-crossed:

can somebody help me to figure out how to put webview in this code .

here is my code which i am implementing .

package wei.mark.example;

import java.util.Locale;

import wei.mark.standout.StandOutWindow;
import wei.mark.standout.constants.StandOutFlags;
import wei.mark.standout.ui.Window;
import android.app.ProgressDialog;
import android.content.Intent;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.webkit.WebView;
import android.widget.FrameLayout;
import android.widget.Toast;
import android.widget.VideoView;

public class SimpleWindow extends StandOutWindow {
private static ProgressDialog progressDialog;
private String mainString = "rtsp://217.146.95.166:554/live/ch33yqcif.3gp";
private VideoView localVideoView;

@Override
public String getAppName() {
return "SimpleWindow";
}

@Override
public int getAppIcon() {
return android.R.drawable.ic_menu_close_clear_cancel;
}

@Override
public void createAndAttachView(int id, FrameLayout frame) {
// create a new layout from body.xml
LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
View view = inflater.inflate(R.layout.simple, frame, true);
localVideoView = (VideoView) view.findViewById(R.id.videoview);
// String mainString = getIntent().getExtras().getString("playthis");
Toast.makeText(SimpleWindow.this, getAppName() + " is " + mainString,
Toast.LENGTH_SHORT).show();

localVideoView.setVideoURI(Uri.parse(mainString));
localVideoView.requestFocus();
localVideoView
.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
public void onPrepared(MediaPlayer paramAnonymousMediaPlayer) {
// SimpleWindow.progressDialog.dismiss();
localVideoView.start();
}
});
}

@Override
public void onReceiveData(int id, int requestCode, Bundle data,
Class<? extends StandOutWindow> fromCls, int fromId) {
// receive data from WidgetsWindow's button press
// to show off the data sending framework
switch (requestCode) {
case MultiWindow.DATA_CHANGED_TEXT:
Window window = getWindow(id);

this.mainString = data.getString("PlayerThis");
Toast.makeText(SimpleWindow.this,
getAppName() + " is " + mainString, Toast.LENGTH_SHORT)
.show();
String s2 = mainString.replace("&myownplayer", "");

progressDialog = ProgressDialog.show(this, "",
"Buffering video...", true);
progressDialog.setCancelable(true);
localVideoView.setVideoURI(Uri.parse(s2));
localVideoView.requestFocus();
localVideoView
.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
public void onPrepared(
MediaPlayer paramAnonymousMediaPlayer) {
SimpleWindow.progressDialog.dismiss();
localVideoView.start();
}
});
break;
default:
Log.d("MultiWindow", "Unexpected data received.");
break;
}
}

// the window will be centered
@Override
public StandOutLayoutParams getParams(int id, Window window) {
return new StandOutLayoutParams(id, 250, 300,
StandOutLayoutParams.CENTER, StandOutLayoutParams.CENTER);
}

// move the window by dragging the view
@Override
public int getFlags(int id) {
return super.getFlags(id) | StandOutFlags.FLAG_BODY_MOVE_ENABLE
| StandOutFlags.FLAG_WINDOW_FOCUSABLE_DISABLE
| StandOutFlags.FLAG_WINDOW_HIDE_ENABLE
| StandOutFlags.FLAG_WINDOW_BRING_TO_FRONT_ON_TAP
| StandOutFlags.FLAG_WINDOW_EDGE_LIMITS_ENABLE
| StandOutFlags.FLAG_WINDOW_PINCH_RESIZE_ENABLE;
}

@Override
public String getPersistentNotificationMessage(int id) {
return "Click to close the SimpleWindow";
}

@Override
public String getPersistentNotificationTitle(int id) {
return getAppName() + " Running";
}

// return an Intent that creates a new MultiWindow

@Override
public int getHiddenIcon() {
return android.R.drawable.ic_menu_info_details;
}

@Override
public String getHiddenNotificationTitle(int id) {
return getAppName() + " Hidden";
}

@Override
public String getHiddenNotificationMessage(int id) {
return "Click to restore #" + id;
}

// return an Intent that restores the MultiWindow
@Override
public Intent getHiddenNotificationIntent(int id) {
return StandOutWindow.getShowIntent(this, getClass(), id);
}

@Override
public Animation getShowAnimation(int id) {
if (isExistingId(id)) {
// restore
return AnimationUtils.loadAnimation(this,
android.R.anim.slide_in_left);
} else {
// show
return super.getShowAnimation(id);
}
}

@Override
public Animation getHideAnimation(int id) {
return AnimationUtils.loadAnimation(this,
android.R.anim.slide_out_right);
}

@Override
public Intent getPersistentNotificationIntent(int id) {
return StandOutWindow.getCloseIntent(this, SimpleWindow.class, id);
}
}