2013-03-30 39 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