Android webview

I just need the map from the game, I marked it green, could someone help me with the code?

I would need the card in the middle at the top and that you cannot move it, so that it is fixed and cannot be moved

import android.webkit.WebViewClient; 
import android.view.ViewGroup.LayoutParams; 
import android.webkit.WebView; 
import android.view.ViewGroup; 
import android.app.Activity; 
import android.widget.RelativeLayout; 
import android.widget.FrameLayout; 
import processing.android.CompatUtils; 
import android.view.View;
FrameLayout fl;
Activity act;
WebView web;
WebViewClient wbc;
int webId, start_time, tnt, count;
boolean just_run_once;
String list = "https://www.championsofregnum.com/?l=5&sec=3";

void setup() { 
  orientation(PORTRAIT);
  background(0, 0, 80);
  start_time = millis();
  just_run_once = true;
  tnt = 255;
  textSize(40);
  textAlign(CENTER);
} 

void settings() {
  fullScreen();
}

void draw() { 
  if (just_run_once) {
    background(0, 0, 80);
    //mage(startlogo, 0, 0);
    //tint(255, tnt);
    //tnt -= 5;
    if (millis()-start_time > 3000) { 
      act.runOnUiThread(
        new Runnable() {
        public void run() {
          WebView wv = (WebView)act.findViewById(webId);
          wv.setVisibility(View.VISIBLE);
        }
      }
      );
      just_run_once = false;
      background(0, 0, 80);
      text("Click to load other video", width/2, 2*height/2.5);
    }
  }
}

void mousePressed() { 
  act.runOnUiThread(
    new Runnable() {   
    public void run() {  
      web.loadUrl(list);
    }
  }
  );
}

void onStop() {
  super.onStop();
  act.finish();
  System.exit(0);
} 

void onPause() {
  super.onPause();
  act.finish ();
  System.exit(0);
} 

void onResume() {
  super.onResume();
}

void onStart() {
  super.onStart();
  act = this.getActivity();
  wbc = new WebViewClient();
  web = new WebView(act);
  web.setLayoutParams(new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.WRAP_CONTENT, 2*height/3));
  web.setWebViewClient(wbc);
  web.getSettings().setJavaScriptEnabled(true);
  web.loadUrl(list);  
  webId = CompatUtils.getUniqueViewId();
  web.setId(webId);
  web.setVisibility(View.GONE);
  fl = (FrameLayout)act.getWindow().getDecorView().getRootView();
  fl.addView(web);
}
2 Likes

I’m unable to run the code that you posted. A blue field is briefly shown and then the app quits. It would be nice to have a WebView demo that is capable of loading your game’s url to start with. The following source code works on my Samsung tablet.

// Android/SketchPermissions check INTERNET

import android.webkit.WebView;
import android.app.Activity;
import android.content.Context;
import android.widget.FrameLayout;
import android.R;

Activity activity;
Context ctx;

void setup() {
  fullScreen();
  activity = this.getActivity();
  ctx = activity.getApplicationContext();
  runOnUiThread(new Runnable() {
    void run() {
      WebView webView = new WebView(ctx);
      webView.loadUrl("https://www.championsofregnum.com/?l=5&sec=3");
      FrameLayout layout = (FrameLayout)activity.findViewById(R.id.content);
      layout.addView(webView);
    }
  }
  );
}

void draw() {
}

In order to change the location of the map I think you would have to edit the html code for the website. You should be able to see that code in a regular browser but I’m not sure how you would edit it to achieve what you want to do.

1 Like