如何保存请求,并在Android应用程序重新发送 [英] how to save request and resend in android app

查看:107
本文介绍了如何保存请求,并在Android应用程序重新发送的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的应用我试图发送一些数据到网络。但应用程序越来越慢,或者当网络不可用得到坠毁。

in my app i am trying to send some data to a network. but the app is getting slow or gets crashed when the network is not available.

如何保存请求后并重新发送一次手机又在网络覆盖范围?

how to save the request for later and resend it once the phone has network coverage again?

如何做到这一点.........

how to do this.........

推荐答案

@Aleadam是正确的,
你应该张贴后您的数据一旦你的互联网连接,但你可以检查通过这种方法你的意图连接。

@Aleadam is right, you should post your data later once your internet is connected, however you can check your intent connection by this method.

public boolean isNetworkAvailable() {
    ConnectivityManager connectivityManager 
          = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
    NetworkInfo activeNetworkInfo = connectivityManager.getActiveNetworkInfo();
    return activeNetworkInfo != null;
}

但这种方法需要进口一些Android的库
这里有这些

but this method will require to import some android libraries here are these

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

我希望这会有所帮助。

I hope this will help.

这篇关于如何保存请求,并在Android应用程序重新发送的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆