android - How can I make a call from external class that extend Activity? -
Hi guys, I'm trying to call a class that increases the activity but gives me a "NullPointerException" error On the other hand if I try to call the same method (which is placed at the end of the main activity) with the main activity java, then it works properly. Why? How can I fix it? I call this method:
public zero prova2 () {try {string url2 = "tel: 33334444"; Intention = Intention = Intent (Int. Action_CALL, Uri. Url2); StartActivity; } Hold (exception e) {e.printStackTrace (); }}
And this is the call from an external class that increases the application:
icosito.setOnClickListener (New OnClickListener) {@Override public void onClick (See V) {main activity prova = new main activity (); prova.prova2 ();}});
Since the method is in MainActivity.java, call will be visible from MainActivity, prova2 ();
Thank you very much.