How do I tell if Intent extras exist in Android?

前端 未结 5 653
你的背包
你的背包 2020-12-23 09:46

I have this code that checks for a value of an extra in an Intent on an Activity that is called from many places in my app:

getIntent().getExtras().getBoolea         


        
5条回答
  •  执笔经年
    2020-12-23 10:14

    You can do this:

    Intent intent = getIntent();
    if(intent.hasExtra("isNewItem")) {
       intent.getExtras().getBoolean("isNewItem");
    }
    

提交回复
热议问题