I try to run an activity after taping a button, but instead of the activity I expected to have, a blank activity runs. The logcat indicates :
W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@6c3e2b4
and I do not understand that.
BuildingActivity.java
public class BuildingActivity extends AppCompatActivity {
private Building mBuilding;
private BaseAdapter adapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_building);
Toolbar toolbar = findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowHomeEnabled(true);
FloatingActionButton fab = findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
//Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
// .setAction("Action", null).show();
Intent intent = new Intent(BuildingActivity.this.getApplication(), AddBase.class);
BuildingActivity.this.startActivity(intent);
}
});
...
AddBase.java
public class AddBase extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
}
}
AddBaseFragment.java
public class AddBaseFragment extends Fragment {
private AddBaseViewModel mViewModel;
public static AddBaseFragment newInstance() {
return new AddBaseFragment();
}
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_add_base, container, false);
}
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mViewModel = ViewModelProviders.of(this).get(AddBaseViewModel.class);
// TODO: Use the ViewModel
}
}
What I don't understand is that it seems to work (displaying the activity correctly) in some of my teams device, but not in mine. So I thought it was a build/clear issue, but none of these worked :/
It seems Like you did not called setContentView() inside the onCreate() of your AddBase Activity.