Android Studio – Switch between Activities – findViewById is null

i have a drawer layout in an base activity. All my Activies inherit from this base activity.

i have two activities. MainActivity Activity2

As long as i am in MainActivity where also my WebView is, everything is working fine.

But when i am on Activity2

WebView myWebView = (WebView) findViewById(; 

myWebView is null.

So how can i go back to MainActivity AND THEN set and URL to myWebView when i am on Activity2?

When i try this and i am in Activity2

WebView myWebView = (WebView) findViewById(;         if(myWebView == null) {           Intent intent = new Intent(getApplicationContext(), MainActivity.class); startActivity(intent); myWebView = (WebView) findViewById(; //myWebView IS STILL NULL!! 

So i hope you understand what my problem is.

The WebView is on MainActivity. If i am on Activity2, i want to go back to MainActivity AND THEN set the url for WebView

i tried so many things like onBackPressed(); or finish() ….

but nothing worked for me

thanks a lot

Erro Null Pointer getCallBack [pendente]

Boa noite, estou tendo um problema com o codigo a baixo, ele estava funcionando perfeitamente, porem do nada resolveu parar de funcionar, no entanto não estou conseguindo entender o problema para estar resolvendo.


Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.Window$ Callback android.view.Window.getCallback()' on a null object reference


import android.annotation.SuppressLint; import; import android.location.Location; import android.os.Bundle; import; import android.view.View; import android.view.animation.Animation; import android.view.animation.LinearInterpolator; import android.view.animation.RotateAnimation; import android.widget.Button; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.ProgressBar; import android.widget.TextView; import android.widget.Toast;  import com.R;  import org.achartengine.ChartFactory; import org.achartengine.GraphicalView; import org.achartengine.model.XYMultipleSeriesDataset; import org.achartengine.model.XYSeries; import org.achartengine.renderer.XYMultipleSeriesRenderer; import org.achartengine.renderer.XYSeriesRenderer;  import java.text.DecimalFormat; import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map;  public class interfaceSpeedTest extends AppCompatActivity {      static int position = 0;     static int lastPosition = 0;     GetSpeedTestHostHandler getSpeedTestHostsHandler;      @Override     public void onResume() {         super.onResume();         getSpeedTestHostsHandler = new GetSpeedTestHostHandler();         getSpeedTestHostsHandler.start();     }      @Override     protected void onCreate(Bundle savedInstanceState) {         super.onCreate(savedInstanceState);         setContentView(R.layout.activity_interface_speed_test);          Button startButton = findViewById(;         final DecimalFormat dec = new DecimalFormat("#.##");         startButton.setText("Iniciar o teste");          final HashSet[] tempBlackList = new HashSet[]{new HashSet<>()};         final GetSpeedTestHostHandler[] getSpeedTestHostsHandler = {new GetSpeedTestHostHandler()};         getSpeedTestHostsHandler[0].start();          startButton.setOnClickListener(new View.OnClickListener() {             public void onClick(View v) {                 Button startButton = findViewById(;                 startButton.setEnabled(false);                  //Reinicia o Test                 if (getSpeedTestHostsHandler[0] == null) {                     getSpeedTestHostsHandler[0] = new GetSpeedTestHostHandler();                     getSpeedTestHostsHandler[0].start();                 }                  new Thread(new Runnable() {                     RotateAnimation rotate;                     ImageView barImageView = findViewById(;                     TextView pingTextView = findViewById(;                     TextView downloadTextView = findViewById(;                     TextView uploadTextView = findViewById(;                      @SuppressLint("ResourceType")                     @Override                     public void run() {                         runOnUiThread(new Runnable() {                             @Override                             public void run() {                                 Button startButton = findViewById(;                                 startButton.setText("Selecionando servidor");                                 modificarAcaoAtual(1);// com base no Ping...                             }                         });                          //Obtem os servidores do speed teste                         int timeCount = 600; //1 min                         while (!getSpeedTestHostsHandler[0].isFinished()) {                             timeCount--;                             try {                                 Thread.sleep(100);                             } catch (InterruptedException e) {                                 e.printStackTrace();                             }                             if (timeCount <= 0) {                                 runOnUiThread(new Runnable() {                                     @Override                                     public void run() {                                         Button startButton = findViewById(;                                         Toast.makeText(getApplicationContext(), "Sem Conexão...", Toast.LENGTH_LONG).show();                                         startButton.setEnabled(true);                                         startButton.setTextSize(16);                                         startButton.setText("Iniciar Novamente");                                     }                                 });                                 getSpeedTestHostsHandler[0] = null;                                 return;                             }                         }                          //Encontra o servidor mais próximo                         HashMap<Integer, String> mapKey = getSpeedTestHostsHandler[0].getMapKey();                         HashMap<Integer, List<String>> mapValue = getSpeedTestHostsHandler[0].getMapValue();                         double selfLat = getSpeedTestHostsHandler[0].getSelfLat();                         double selfLon = getSpeedTestHostsHandler[0].getSelfLon();                         double tmp = 19349458;                         //double dist = 0.0;                         int findServerIndex = 0;                         for (int index : mapKey.keySet()) {                             if (tempBlackList[0].contains(mapValue.get(index).get(5))) {                                 continue;                             }                              Location source = new Location("Source");                             source.setLatitude(selfLat);                             source.setLongitude(selfLon);                              List<String> ls = mapValue.get(index);                             Location dest = new Location("Dest");                             dest.setLatitude(Double.parseDouble(ls.get(0)));                             dest.setLongitude(Double.parseDouble(ls.get(1)));                              double distance = source.distanceTo(dest);                             if (tmp >= distance) {                                 tmp = distance;                                 //dist = distance;                                 findServerIndex = index;                             }                         }                         String uploadAddr = mapKey.get(findServerIndex);                         final List<String> info = mapValue.get(findServerIndex);                         //final double distance = dist;                          if (info == null) {                             runOnUiThread(new Runnable() {                                 @Override                                 public void run() {                                     //Button startButton = findViewById(;                                     //startButton.setTextSize(12);                                     //startButton.setText("Problemas para Obter o Host. Por favor tente mais tarde!");                                     System.out.println("Problemas para Obter o Host. Por favor tente mais tarde!");                                 }                             });                             return;                         }                          //Inicia o grafico do Ping                         final LinearLayout chartPing = findViewById(;                         XYSeriesRenderer pingRenderer = new XYSeriesRenderer();                         XYSeriesRenderer.FillOutsideLine pingFill = new XYSeriesRenderer.FillOutsideLine(XYSeriesRenderer.FillOutsideLine.Type.BOUNDS_ALL);                         pingFill.setColor(Color.parseColor(getApplicationContext().getString(R.color.colorGraphic)));                         pingRenderer.addFillOutsideLine(pingFill);                         pingRenderer.setDisplayChartValues(false);                         pingRenderer.setShowLegendItem(false);                         pingRenderer.setColor(Color.parseColor(getApplicationContext().getString(R.color.colorGraphic)));                         pingRenderer.setLineWidth(5);                         final XYMultipleSeriesRenderer multiPingRenderer = new XYMultipleSeriesRenderer();                         multiPingRenderer.setXLabels(0);                         multiPingRenderer.setYLabels(0);                         multiPingRenderer.setZoomEnabled(false);                         multiPingRenderer.setXAxisColor(Color.parseColor(getApplicationContext().getString(R.color.colorGraphic)));                         multiPingRenderer.setYAxisColor(Color.parseColor(getApplicationContext().getString(R.color.colorGraphic)));                         multiPingRenderer.setPanEnabled(true, true);                         multiPingRenderer.setZoomButtonsVisible(false);                         multiPingRenderer.setMarginsColor(Color.argb(0x00, 0xff, 0x00, 0x00));                         multiPingRenderer.addSeriesRenderer(pingRenderer);                          //Inicia o grafico do Download                         final LinearLayout chartDownload = findViewById(;                         XYSeriesRenderer downloadRenderer = new XYSeriesRenderer();                         XYSeriesRenderer.FillOutsideLine downloadFill = new XYSeriesRenderer.FillOutsideLine(XYSeriesRenderer.FillOutsideLine.Type.BOUNDS_ALL);                         downloadFill.setColor(Color.parseColor(getApplicationContext().getString(R.color.colorGraphic)));                         downloadRenderer.addFillOutsideLine(downloadFill);                         downloadRenderer.setDisplayChartValues(false);                         downloadRenderer.setColor(Color.parseColor(getApplicationContext().getString(R.color.colorGraphic)));                         downloadRenderer.setShowLegendItem(false);                         downloadRenderer.setLineWidth(5);                         final XYMultipleSeriesRenderer multiDownloadRenderer = new XYMultipleSeriesRenderer();                         multiDownloadRenderer.setXLabels(0);                         multiDownloadRenderer.setYLabels(0);                         multiDownloadRenderer.setZoomEnabled(false);                         multiDownloadRenderer.setXAxisColor(Color.parseColor(getApplicationContext().getString(R.color.colorGraphic)));                         multiDownloadRenderer.setYAxisColor(Color.parseColor(getApplicationContext().getString(R.color.colorGraphic)));                         multiDownloadRenderer.setPanEnabled(false, false);                         multiDownloadRenderer.setZoomButtonsVisible(false);                         multiDownloadRenderer.setMarginsColor(Color.argb(0x00, 0xff, 0x00, 0x00));                         multiDownloadRenderer.addSeriesRenderer(downloadRenderer);                          //Inicia o grafico do Upload                         final LinearLayout chartUpload = findViewById(;                         XYSeriesRenderer uploadRenderer = new XYSeriesRenderer();                         XYSeriesRenderer.FillOutsideLine uploadFill = new XYSeriesRenderer.FillOutsideLine(XYSeriesRenderer.FillOutsideLine.Type.BOUNDS_ALL);                         uploadFill.setColor(Color.parseColor(getApplicationContext().getString(R.color.colorGraphic)));                         uploadRenderer.addFillOutsideLine(uploadFill);                         uploadRenderer.setDisplayChartValues(false);                         uploadRenderer.setColor(Color.parseColor(getApplicationContext().getString(R.color.colorGraphic)));                         uploadRenderer.setShowLegendItem(false);                         uploadRenderer.setLineWidth(5);                         final XYMultipleSeriesRenderer multiUploadRenderer = new XYMultipleSeriesRenderer();                         multiUploadRenderer.setXLabels(0);                         multiUploadRenderer.setYLabels(0);                         multiUploadRenderer.setZoomEnabled(false);                         multiUploadRenderer.setXAxisColor(Color.parseColor(getApplicationContext().getString(R.color.colorGraphic)));                         multiUploadRenderer.setYAxisColor(Color.parseColor(getApplicationContext().getString(R.color.colorGraphic)));                         multiUploadRenderer.setPanEnabled(false, false);                         multiUploadRenderer.setZoomButtonsVisible(false);                         multiUploadRenderer.setMarginsColor(Color.argb(0x00, 0xff, 0x00, 0x00));                         multiUploadRenderer.addSeriesRenderer(uploadRenderer);                          //Reinicia os valores do grafico                         runOnUiThread(new Runnable() {                             @Override                             public void run() {                                 pingTextView.setText("0 ms");                                 chartPing.removeAllViews();                                 downloadTextView.setText("0 Mbps");                                 chartDownload.removeAllViews();                                 uploadTextView.setText("0 Mbps");                                 chartUpload.removeAllViews();                             }                         });                         final List<Double> pingRateList = new ArrayList<>();                         final List<Double> downloadRateList = new ArrayList<>();                         final List<Double> uploadRateList = new ArrayList<>();                         boolean pingTestStarted = false;                         boolean pingTestFinished = false;                         boolean downloadTestStarted = false;                         boolean downloadTestFinished = false;                         boolean uploadTestStarted = false;                         boolean uploadTestFinished = false;                          //Inicia o test                         final PingTest pingTest = new PingTest(info.get(6).replace(":8080", ""), 6);                         //System.out.println(info.get(6));                         assert uploadAddr != null;                         final HttpDownloadTest downloadTest = new HttpDownloadTest(uploadAddr.replace(uploadAddr.split("/")[uploadAddr.split("/").length - 1], ""));                         final HttpUploadTest uploadTest = new HttpUploadTest(uploadAddr);                          for (Map.Entry<Integer,String> entry: mapKey.entrySet()){                             System.out.println("Vetor: "+entry);                         }                         System.out.println("Donwload/Upload address: "+ uploadAddr);  //                      //Testes                         while (true) {                             if (!pingTestStarted) {                                 pingTest.start();                                 pingTestStarted = true;                             }                             if (pingTestFinished && !downloadTestStarted) {                                 downloadTest.start();                                 downloadTestStarted = true;                             }                             if (downloadTestFinished && !uploadTestStarted) {                                 uploadTest.start();                                 uploadTestStarted = true;                             }                              //Ping Test                             if (pingTestFinished) {                                 //Failure                                 if (pingTest.getAvgRtt() == 0) {                                     System.out.println("Ping error...");                                 } else {                                     //Success                                     runOnUiThread(new Runnable() {                                         @Override                                         public void run() {                                             pingTextView.setText(dec.format(pingTest.getAvgRtt()) + " ms");                                         }                                     });                                 }                             } else {                                 pingRateList.add(pingTest.getInstantRtt());                                  runOnUiThread(new Runnable() {                                     @Override                                     public void run() {                                         pingTextView.setText(dec.format(pingTest.getInstantRtt()) + " ms");                                     }                                 });                                  //Update chart                                 runOnUiThread(new Runnable() {                                     @Override                                     public void run() {                                         // Creating an  XYSeries for Ping                                         XYSeries pingSeries = new XYSeries("");                                         pingSeries.setTitle("");                                          int count = 0;                                         List<Double> tmpLs = new ArrayList<>(pingRateList);                                         for (Double val : tmpLs) {                                             pingSeries.add(count++, val);                                         }                                          XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();                                         dataset.addSeries(pingSeries);                                          GraphicalView chartView = ChartFactory.getLineChartView(getBaseContext(), dataset, multiPingRenderer);                                         chartPing.addView(chartView, 0);                                      }                                 });                             }                              //Download Test                             if (pingTestFinished) {                                 if (downloadTestFinished) {                                     //Failure                                     if (downloadTest.getFinalDownloadRate() == 0) {                                         System.out.println("Download error...");                                     } else {                                         //Success                                         runOnUiThread(new Runnable() {                                             @Override                                             public void run() {                                                 downloadTextView.setText(dec.format(downloadTest.getFinalDownloadRate()) + " Mbps");                                             }                                         });                                     }                                 } else {                                     //Calc position                                     double downloadRate = downloadTest.getInstantDownloadRate();                                     downloadRateList.add(downloadRate);                                     position = getPositionByRate(downloadRate);                                      runOnUiThread(new Runnable() {                                          @Override                                         public void run() {                                             rotate = new RotateAnimation(lastPosition, position, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);                                             rotate.setInterpolator(new LinearInterpolator());                                             rotate.setDuration(100);                                             barImageView.startAnimation(rotate);                                             downloadTextView.setText(dec.format(downloadTest.getInstantDownloadRate()) + " Mbps");                                          }                                      });                                     lastPosition = position;                                      //Update chart                                     runOnUiThread(new Runnable() {                                         @Override                                         public void run() {                                             // Creating an  XYSeries for download                                             XYSeries downloadSeries = new XYSeries("");                                             downloadSeries.setTitle("");                                              List<Double> tmpLs = new ArrayList<>(downloadRateList);                                             int count = 0;                                             for (Double val : tmpLs) {                                                 downloadSeries.add(count++, val);                                             }                                              XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();                                             dataset.addSeries(downloadSeries);                                              GraphicalView chartView = ChartFactory.getLineChartView(getBaseContext(), dataset, multiDownloadRenderer);                                             chartDownload.addView(chartView, 0);                                         }                                     });                                  }                             }                              //Upload Test                             if (downloadTestFinished) {                                 if (uploadTestFinished) {                                     //Failure                                     if (uploadTest.getFinalUploadRate() == 0) {                                         System.out.println("Upload error...");                                     } else {                                         //Success                                         runOnUiThread(new Runnable() {                                             @Override                                             public void run() {                                                 uploadTextView.setText(dec.format(uploadTest.getFinalUploadRate()) + " Mbps");                                             }                                         });                                     }                                 } else {                                     //Calc position                                     double uploadRate = uploadTest.getInstantUploadRate();                                     uploadRateList.add(uploadRate);                                     position = getPositionByRate(uploadRate);                                      runOnUiThread(new Runnable() {                                          @Override                                         public void run() {                                             rotate = new RotateAnimation(lastPosition, position, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);                                             rotate.setInterpolator(new LinearInterpolator());                                             rotate.setDuration(100);                                             barImageView.startAnimation(rotate);                                             uploadTextView.setText(dec.format(uploadTest.getInstantUploadRate()) + " Mbps");                                         }                                      });                                     lastPosition = position;                                      //Update chart                                     runOnUiThread(new Runnable() {                                         @Override                                         public void run() {                                             // Creating an  XYSeries for upload                                             XYSeries uploadSeries = new XYSeries("");                                             uploadSeries.setTitle("");                                              int count = 0;                                             List<Double> tmpLs = new ArrayList<>(uploadRateList);                                             for (Double val : tmpLs) {                                                 if (count == 0) {                                                     val = 0.0;                                                 }                                                 uploadSeries.add(count++, val);                                             }                                              XYMultipleSeriesDataset dataset = new XYMultipleSeriesDataset();                                             dataset.addSeries(uploadSeries);                                              GraphicalView chartView = ChartFactory.getLineChartView(getBaseContext(), dataset, multiUploadRenderer);                                             chartUpload.addView(chartView, 0);                                         }                                     });                                  }                             }                              //Executa Ping, Download e Upload                             if (pingTestFinished && downloadTestFinished && uploadTest.isFinished()) {                                 break;                             }                              if (pingTest.isFinished()) {                                 pingTestFinished = true;                             }                             if (downloadTest.isFinished()) {                                 downloadTestFinished = true;                             }                             if (uploadTest.isFinished()) {                                 uploadTestFinished = true;                             }                              if (!pingTestFinished) {                                 try {                                     Thread.sleep(300);                                 } catch (InterruptedException e) {                                 }                             } else {                                 try {                                     Thread.sleep(100);                                 } catch (InterruptedException e) {                                 }                             }                         }                          //Ativação do botão novamente                         runOnUiThread(new Runnable() {                             @Override                             public void run() {                                 modificarAcaoAtual(0);                                 Button startButton = findViewById(;                                 startButton.setEnabled(true);                                 startButton.setTextSize(16);                                 startButton.setText("Iniciar Novamente");                             }                         });                       }                 }).start();             }         });     }      public void closeTest(View view) throws Throwable {         finish();     }      public void modificarAcaoAtual(final int progress){         final ProgressBar progressBar = findViewById(;         runOnUiThread(new Runnable() {              @Override             public void run() {                  if (progress == 0){                     progressBar.setVisibility(View.GONE);                 } else {                     progressBar.setVisibility(View.VISIBLE);                 }              }         });     }      public int getPositionByRate(double rate) {         if (rate <= 1) {             return (int) (rate * 30);          } else if (rate <= 10) {             return (int) (rate * 6) + 30;          } else if (rate <= 30) {             return (int) ((rate - 10) * 3) + 90;          } else if (rate <= 50) {             return (int) ((rate - 30) * 1.5) + 150;          } else if (rate <= 100) {             return (int) ((rate - 50) * 1.2) + 180;         }          return 0;     } } ```  

Unable to get property ‘get_current’ of undefined or null reference in JSLink on list view

we need to filter list view items based on some conditions for which we need current context(sp.ClientContext). but we are getting undefined or null reference. we have also followed the solution provided by Vadim Gremyachev on Stack exchange

but as soon as the sp.js loads; list view also gets load. so whatever condition we want to apply to filter out list view items does not work as the required code starts working after list view loads.

Please suggest how we can solve this problem.

How is it possible that a null pointer still retains a memory adress?

When you initialize a pointer with nothing(NULL), that element still has a memory address big enough for the initialising type of that pointer(4 bytes for int, 1 for char etc.) but why,since it’s tehnically nothing, not even the value zero? I mean, NULL can’t be a fixed value like 0 because zero still is considered a value, so it is something more than that? Example:

#include <iostream>  int *a=NULL; int main() {     std::cout <<&a; //it will show the address in hexadecimal system;     return 0; } 

Request Failed Unexpected response from server. The status code of response is ‘500’. The status text of response is ‘internal server error’. null

I have created the “Business Intelligence Center Site” and I have to create dashboards.I have activated the required features at site level and site collection level also.Yet when I click on the ‘dashboard design’ in performancepoint tab of PerformancePoint Content list ribbon, it is showing me error as “Request Failed Unexpected response from server. The status code of response is ‘500’. The status text of response is ‘internal server error’. null “. It was working fine at starting. And I already downloaded the “Dashboard Designer” too. But later on that dashboard designer too is not connecting with the server. Why is it happening so. I did lot of finding and tried many solutions yet it is not working.

LetsEncrypt TLS Cert invalid? “EVP_MD_size:message digest is null”

I am finding this in my logs for postfix, I’m using a LetsEncrypt certificate but I’m unable to find any useful information online about it. Does anybody know if this is a problem or something that isn’t important?

postfix/smtpd[526]: warning: TLS library problem: error:060A209F:digital envelope routines:EVP_MD_size:message digest is null:crypto/evp/evp_lib.c:316:

Ошибка Spring: AbstractApplicationContext#getBean(Class requiredType) выдает null

Нужна ваша помощь и подсказка. Дело, думаю, в какой-то мелочи, которую я в упор не вижу. Ковыряю потихоньку Spring по лекции Евгения Борисова ( и столкнулся с такой проблемой (репозиторий с проектом на гитхабе – выполнение кода падает с ошибкой:

апр 20, 2019 6:21:16 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions INFO: Loading XML bean definitions from class path resource [common_beans.xml] Exception in thread "main" java.lang.NullPointerException     at redbeard.Runner.main(  Process finished with exit code 1 


ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("common_beans.xml"); 

отрабатывает нормально, бин из common_beans.xml с id=’terminatorQuoter’ настраивается, то есть в поле repeat бина terminatorQuoter выставляется нужное значение: введите сюда описание изображения

Ошибка именно в


потому что:

 context.getBean(TerminatorQuoter.class) выдает null 

введите сюда описание изображения

Однако, если я убираю все, что связано с аннотацией InjectRandomInt, то есть ее вообще не использую, и в методе sayQuote() просто вывожу сообщение:


то все работает. Подскажите, где что упустил. Хотя лекцию несколько раз пересмотрел, тщательно выверил все, что сделал.

Buffer overflow return address with null byte, workaround

Practising BO using Free Float FTP Server 1.0 on Windows 7 SP1, done simple jmp esp examples on Win XP where system DLL are without rebase or ASLR, trying to write one for Win7 where I haven’t got any system DLL with rebase or ASLR disabled, I can still exploit it but it won’t survive reboot, so I’m very much left with opcodes from the FTPServer.exe but the problem is that they all use a low stack addresses (0x0040xxxx) , so they all end with NULL byte (eg, \xce\x11\x40\x00 ) and hence terminate my exploit. My question is what are the options, if any to workaround the NULL byte in address I want to use, more specifically I want to know whenever there is an option to use NULL byte at the end of return address if it is listed as a bad character?