在主要活动中:
download.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
ThreadProcess threadProcess = new ThreadProcess();
threadProcess.execute();
在ThreadProcess类(extends
AsyncTask)中,我重写了方法onPostExecute()
以启动浏览器意图。我无法做到这一点。请帮忙。
答案 0 :(得分:0)
@Override
protected void onPostExecute(String s) {
String url = "https://www.stackoverflow.com";
Intent browserIntent = new Intent(Intent.ACTION_VIEW);
browserIntent.setData(Uri.parse(url));
startActivity(browserIntent);
}
答案 1 :(得分:0)
尝试一下:
download.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent openWebsite = new Intent(Intent.ACTION_VIEW, Uri.parse("www.myWebsite.com")); //Insert website.
startActivity(openWebsite);
}
});