Android Studio
1:仅打开一次活动并保存URL链接
2:在webview中获取此链接
myWebView.loadUrl(“url link”);
谢谢和问候
答案 0 :(得分:1)
我不确定您需要澄清什么,因为您已经回答了自己的问题(无论您是否意识到这一点)
public class MyActivity extends Activity {
WebView webView;
// You can define as many of these as you like
String urlString1 = "www.google.com";
String urlString2 = "www.facebook.com";
...
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
webView = (WebView) findViewById(R.id.my_web_view_id):
...
webView.loadUrl(new Url(urlString));
}
}
如果您想使用共享偏好设置:
// initialize prefs
SharedPreferences sharedPreferences = getSharedPreferences("some_string_identifier" , Context.MODE_PRIVATE);
// get url
urlString1 = sharedPreferences.getString("url", null);
// save url
Editor editor = sharedPreferences.edit();
editor.putString("url", urlString1);
editor.commit();