私のアプリケーションにはサービスがあり、必要なものが含まれているstrings.xmlファイルにアクセスするにはどうすればいいですか?サービスでstrings.xmlファイルを使用する方法は?
strings.xmlにある文字列を取得したいのですが、私のサービスでこのファイルにアクセスできません。
私はこの問題が文脈を扱うと思っていますが、解決できません。あなたの助けのための
package com.receiver;
protected Void doInBackground() {
// GPS timeout
final int maxSeconds = 60; //30
int count = 0;
// If we've finished finding location or exceeded timeout,
// break the loop.
while (findingLocation && count < maxSeconds) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// Continue if interrupted
}
// Increment the timer by one second
count++;
}
// If we're still finding location, switch to network locations.
if (findingLocation) {
locationHandler.sendMessage(new Message());
locationManager.removeUpdates(SMSReceiver.this);
lat = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER).getLatitude();
lng = locationManager.getLastKnownLocation(LocationManager.NETWORK_PROVIDER).getLongitude();
msg = "";// here I whant to get my string from the strings.xml but I can't access to this file
} else {
lat = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER).getLatitude();
lng = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER).getLongitude();
msg = " "; // here I whant to get other string from the strings.xml but I can't access to this file
}
ありがとう:
私のサービスの抽出物があります。
私の悪い英語のために申し訳ありません。
ありがとうございました。 – user1212077