I am making a LibGDX app, and I need to get the view to put to an Android app. Here is the code to get the view:
package jangkoo.game.shadowfiend.android;
import jangkoo.game.shadowfiend.ShadowFiendGame;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import com.badlogic.gdx.backends.android.AndroidApplication;
import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration;
public class LibGdx extends AndroidApplication {
private static final String TAG = "LibGDx";
public View view;
Bundle savedInstanceState;
@Override
protected void onCreate (Bundle savedInstanceState) {
if(savedInstanceState == null)
this.savedInstanceState = getIntent().getExtras();
Log.e(TAG,savedInstanceState + "");
super.onCreate(savedInstanceState);
AndroidApplicationConfiguration config = new AndroidApplicationConfiguration();
view = initializeForView(new ShadowFiendGame(), config);
}
public LibGdx(){
onCreate(new Bundle());
}
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
}
}
And I want to get the libGDX.view from this,for a class that doesn't extend AndroidApplication.
protected void onCreate (Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
interstitialAd = new IntestialAds(this);
inflater = LayoutInflater.from(this);
config = new AndroidApplicationConfiguration();
libGdx = new LibGdx();
Log.e(TAG,libGdx.view + "");
}
However, the onCreate function has nullpointer exception. How can I handle this?