Need Context when no activity is running

前端 未结 5 469
离开以前
离开以前 2021-01-26 08:16

I am displaying a pop up from Notification of my application.But when I check my notification no activity is running from my application so in notification when I show dialogue

5条回答
  •  暖寄归人
    2021-01-26 09:05

    I suffered with the same issue. I can't able to use the spinner in my activity. I solved this by using the setContentView like as following

    public void onCreate(Bundle savedInstanceState) 
    {   
     super.onCreate(savedInstanceState);
     View viewToLoad = LayoutInflater.from(this.getParent()).inflate(R.layout.main, null);
            this.setContentView(viewToLoad);
    }
    

    Another way you can use the separate activity for you dialog. By setting activity like follows

    style.xml
    
    
    
        
    
    
    

    In AndroidManifest Declare activity like this

    
    

提交回复
热议问题