2016-09-19 5 views
-1

「このメソッドはrequestLocationUpdatesメソッドを解決できません」というエラーが表示されます。私はもう何をすべきか分からず、フラグメントを使用しているので、すでに "this"を "getActivity"に変更しました。フラグメントマネージャーでこのエラーが発生しました

ところで、このコードは別のプロジェクトから試してみましたが、断片にはありません。私はフラグメントでこれをやろうとしましたが、これがエラーを起こす場所です。

ここに私のコードです:ここで

@Override 
public View onCreateView(LayoutInflater inflater, ViewGroup container, 
         Bundle savedInstanceState) { 
    // Inflate the layout for this fragment 
    View view = inflater.inflate(R.layout.fragment_recipients, container, false); 

    LocationManager locationManager = (LocationManager) getActivity().getSystemService(Context.LOCATION_SERVICE); 
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 5000, 10, getActivity()); 

    button = (Button) view.findViewById(R.id.button2); 
    button.setOnClickListener(new View.OnClickListener(){ 

     @Override 
     public void onClick(View v) { 

      String uri = "http://maps.google.com/?q="+latitude +","+longitude; 
      StringBuffer smsBody = new StringBuffer(); 

      smsBody.append(Uri.parse(uri)); 
      String msg = (" Hello, Timothy. You are at" + " " + longitude + " " + latitude).toString(); 

      try { 

       SmsManager smsManager = SmsManager.getDefault(); 
       smsManager.sendTextMessage(phoneNo, null, smsBody.toString(), null, null); 



       Toast.makeText(getContext(), "Message Sent", 
         Toast.LENGTH_LONG).show(); 
      } catch (Exception ex) { 
       Toast.makeText(getContext(), 
         ex.getMessage().toString(), 
         Toast.LENGTH_LONG).show(); 
       ex.printStackTrace(); 
      } 



     } 
    }); 
    return view; 
} 

は私の輸入品は以下のとおりです。事前に

import android.location.Location; 
import android.location.LocationListener; 
import android.location.LocationManager; 
import android.net.Uri; 
import android.os.Bundle; 
import android.app.Activity; 
import android.content.Context; 
import android.content.Intent; 
import android.view.Menu; 
import android.telephony.SmsManager; 
import android.view.View; 
import android.view.View.OnClickListener; 
import android.widget.Button; 
import android.widget.EditText; 
import android.widget.Toast; 

ありがとう!

+0

acOutputReportを使用していますが、クエリ名を指定しています。 acOutputReportを使用する場合は、レポート名を指定する必要があります。 acOutputQueryを使用するか、クエリに基づいて新しいレポートを作成してから、acOutputReport、 "NewReportName"を使用するようです。詳細については、[Microsoftのページ](https://msdn.microsoft.com/en-us/library/office/ff192065.aspx)を参照してください。 –

答えて

0

acOutputReportを使用していますが、クエリ名を指定しています。 acOutputReportを使用する場合は、レポート名を指定する必要があります。 acOutputQueryを使用するか、クエリに基づいて新しいレポートを作成してから、acOutputReport、 "NewReportName"を使用するようです。

詳細はMicrosoft's page on the OutputTo methodをご覧ください。

関連する問題