If OnCreateView is only for fragments, what would be for Activity?
I tried OnCreate() and I cannot make it work
In the first Override I have problems, and in the last Overide it also give me an error for the OncreateView.
I have read about OnCreate() and OnCreateView(), but I cannot find the answer.
private VrPanoramaView panoWidgetView;
private ImageLoaderTask backgroundImageLoaderTask;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View v = inflater.inflate(R.layout.activity_pruebafoto, container,false);
panoWidgetView = v.findViewById(R.id.pano_view);
return v;
}
@Override
public void onPause() {
panoWidgetView.pauseRendering();
super.onPause();
}
@Override
public void onResume() {
panoWidgetView.resumeRendering();
super.onResume();
}
@Override
public void onDestroy() {
// Destroy the widget and free memory.
panoWidgetView.shutdown();
super.onDestroy();
}
private synchronized void loadPanoImage() {
ImageLoaderTask task = backgroundImageLoaderTask;
if (task != null && !task.isCancelled()) {
// Cancel any task from a previous loading.
task.cancel(true);
}
// pass in the name of the image to load from assets.
VrPanoramaView.Options viewOptions = new VrPanoramaView.Options();
viewOptions.inputType = VrPanoramaView.Options.TYPE_STEREO_OVER_UNDER;
// use the name of the image in the assets/ directory.
String panoImageName = "@drawable/iglesiavr.jpg";
// create the task passing the widget view and call execute to start.
task = new ImageLoaderTask(panoWidgetView, viewOptions, panoImageName);
task.execute(this.getAssets());
backgroundImageLoaderTask = task;
}
@Override
public void onCreateView(@Nullable Bundle savedInstanceState) {
super.onCreateView(savedInstanceState);
loadPanoImage();
}
onCreateView()
is called only on fragment if it is an activity you may useonCreate()
method. for further details refer this flow diagram of lifecycles.https://github.com/xxv/android-lifecycle