Uri uri = Uri.parse(getString(R.string.homepage_uri))有用到了getString函数,它来自android.content.Context。此时,
没有在开头增加import android.content.Context,程序运行正常。
在开头增加import android.content.Context,程序报“从未使用导入 android.content.Context”警告。难道getString函数,不用任何的import包吗?帮助如下:
 String android.content.Context.getString(int resId)
Return a localized string from the application's package's default string table.参数:
resId Resource id for the stringpublic void onClick(DialogInterface dialog, int which)
{
//go to url
Uri uri = Uri.parse(getString(R.string.homepage_uri));
Intent intent = new Intent(Intent.ACTION_VIEW, uri);
startActivity(intent);
}