W/ActivityThread:handleWindowVisibility:没有 activity 令牌 android.os.BinderProxy@6c3e2b4

W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@6c3e2b4

我尝试在点击按钮后 运行 一个 activity,但我期望的 activity 不是空白 activity 运行秒。 logcat 表示:

W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@6c3e2b4

我不明白。

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
    }

}

我不明白的是,它似乎在我的某些团队设备中有效(正确显示 activity),但在我的设备中无效。所以我认为这是一个 build/clear 问题,但其中 none 有效:/

您似乎没有在 AddBase 的 onCreate() 中调用 setContentView() Activity。