ブラウザー ウィンドウを開いて特定の URL を呼び出すように、callerid アプリを変更したいと考えています。呼び出しが着信すると、以下のコードは URL に発信し、発信者情報を返します。これはうまくいきます。私が抱えている問題は、事前にフォーマットされた URL で電話のデフォルト ブラウザも開きたいということです。http://www.myurl.com/index.php?action=getCallerInformation&number=phoneNumber.toString () のようなもの私が持っているコードは
package com.integralblue.callerid;
import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;
import org.springframework.http.HttpStatus;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate;
import roboguice.inject.InjectResource;
import android.content.SharedPreferences;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import com.google.inject.Inject;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
public class HttpCallerIDLookup implements CallerIDLookup {
@Inject SharedPreferences sharedPreferences;
@InjectResource(R.string.default_lookup_url) String defaultLookupUrl;
@Inject RestTemplate restTemplate;
@Inject TelephonyManager telephonyManager;
public CallerIDResult lookup(final CharSequence phoneNumber) throws NoResultException {
//use the network's country if it's available (as I figure that's probably the best? I'm just guessing)
//if the network's country isn't available, using the SIM's
//I have no idea how or if this works on CDMA networks
//(Android documentation warns that these function may not work as expected with CDMA)
final String agentCountry = TextUtils.isEmpty(telephonyManager.getNetworkCountryIso())?telephonyManager.getNetworkCountryIso():telephonyManager.getSimCountryIso();
final String beforeSubstitutionLookupUrl = sharedPreferences.getString("lookup_url", defaultLookupUrl);
final String url;
final Intent intent = new Intent(Intent.ACTION_VIEW).setData(Uri.parse("http://www.myurl.com/index.php?action=getCallerInformation&number=phoneNumber.toString()"));
startActivity(intent);
if(beforeSubstitutionLookupUrl.contains("{0}")){
// ensure backwards compatibility. The URL used to use {0} and {1}
url = MessageFormat.format(beforeSubstitutionLookupUrl, "{number}", "{agentCountry}");
}else{
url = beforeSubstitutionLookupUrl;
}
final Map<String, String> urlVariables = new HashMap<String, String>();
urlVariables.put("number", phoneNumber.toString());
urlVariables.put("agentCountry", agentCountry);
try{
return restTemplate.getForObject(url, CallerIDResult.class, urlVariables);
}catch(HttpClientErrorException e){
if(HttpStatus.NOT_FOUND.equals(e.getStatusCode())){
throw new NoResultException();
}else{
throw new RuntimeException(e);
}
}catch(Exception e){
throw new RuntimeException(e);
}
}
}
コンパイルすると、startActivity(intent); について不平を言います。シンボルを見つけることができません