2013-03-30 40 views
0

我试图在我的活动中烤面包。我的活动首先与GoogleMap的膨胀在为什么吐司在谷歌地图中不起作用

protected void onCreate(Bundle savedInstanceState) { 
      super.onCreate(savedInstanceState);  
      setContentView(R.layout.activity_detail_map_view); 
} 

然后,我设置了土司在onResume()

public void onResume() { 
    super.onResume(); 

    //---create the BroadcastReceiver when the SMS is sent--- 
     smsSentReceiver = new BroadcastReceiver(){ 
      @Override 
      public void onReceive(Context arg0, Intent arg1) { 

       switch (getResultCode()) 
       { 
        case Activity.RESULT_OK: 
         Toast.makeText(getBaseContext(), "SMS sent", 
          Toast.LENGTH_SHORT).show(); 
         break; 

但它应该是敬酒的时候,我没有看到敬酒。 什么可能是错的? 感谢

+0

尝试ActivityName.this代替getBaseContext() – Raghunandan

回答

0

不要使用getApplicationContext:尝试

Toast.makeText(youractivity.this,"SMS Sent",Toast.LENGTH_SHORT).show(); 

还与

Toast.makeText(context,"SMS Sent",Toast.LENGTH_SHORT).show(); 
+0

尝试当我使用这个我有“的错误方法makeText(Context,CharSequence,int)在Toast类型中不适用于参数(new BroadcastReceiver(){},String,int)“ – Bryanyan

+0

检查我编辑的答案。请研究basecontext,applicationcontext和 –

+0

之间的区别。谢谢你是对的。我还有一个问题。 – Bryanyan