У меня есть служба в моем приложении, и я хочу получить доступ к файлу 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
}
Спасибо за вашу помощь.
Извините за мой плохой английский.