1
我在webview中的應用程序中加載url但在webview下載功能時沒有發生什麼事情請點擊下載按鈕給我的解決方案。我已經在webview中加載url,但下載功能不能在webview中點擊下載按鈕
Public class FinancialActivity extends AppCompatActivity {
WebView webview;
public static final String SHARED_PREF_NAME = "myloginapp";
SharedPreferences sharedPreferences;
String id, studid, degree, user_type;
String url;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_financial);
sharedPreferences = FinancialActivity.this.getSharedPreferences(SHARED_PREF_NAME, Context.MODE_PRIVATE);
studid = sharedPreferences.getString(LoginActivity.ID_SHARED_PREF, "Not Available");
degree = sharedPreferences.getString(LoginActivity.KEY_DEGREE_SOUGHT, "Not Available");
user_type = sharedPreferences.getString("user_type", "Not Available");
url = Urlinfo.Financial + "stud_id=" + studid + "&user_type=" + user_type + "&subscription_status=" + DrawerActivity.subvalue + "&stud_degree=" + degree;
Log.d("urlapplication", "" + url);
WebView w = new WebView(this);
w.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
});
w.setDownloadListener(new DownloadListener() {
public void onDownloadStart(String url, String userAgent,
String contentDisposition, String mimetype,
long contentLength) {
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse(url));
startActivity(i);
}
});
setContentView(w);
w.loadUrl(url);
}
}
}
? –
是............. –
檢查下面的答案 –