开发者

taking time when going from one activity to another by button click

When I am going from one activity to another by button click, in my second activity I am displaying an advertisement in webview i开发者_高级运维n the top position. It is coming from a url so it takes time to navigate to another activity, so I want to ask: is there any solution for do it after i navigate to next activity and then download of image begins.

In on create, I wrote this code:

     SharedPreferences BannerPrefs = getSharedPreferences("BannerPref", 0);
     BannerLink = BannerPrefs.getString("BannerLink", "");
     BannerUrl = BannerPrefs.getString("BannerUrl", "");
     WebView wv=(WebView)findViewById(R.id.imv);
     wv.setOnTouchListener(new OnTouchListener() {



     @Override
     public boolean onTouch(View v, MotionEvent event) {
        final Intent intent = new                  Intent(Intent.ACTION_VIEW).setData(Uri.parse(BannerLink));
        startActivity(intent);          
        return false;
     }
     });
     wv.loadUrl(BannerUrl);

Thanks


you should use thread to fetch data and as soon as you get it update it using Handler ..You can use AsyncTask for this.

for AsyncTask refer this doc:

http://developer.android.com/reference/android/os/AsyncTask.html

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜