android mms download mms content through mms url

本秂侑毒 提交于 2019-12-03 02:16:45

Now I am able to find out the solution but I find that sometime the download code doesn't work but when you try again it works although what I was missing first establishing the connectivity to the server. I have mention below the connectivity method and after this call the method name downloadThroughGateway(parameters) which is mention on this question code.

private void startConnectivity() throws Exception {
        ConnectivityManager mConnMgr = (ConnectivityManager) context
                .getSystemService(Context.CONNECTIVITY_SERVICE);
        if (!mConnMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE_MMS)
                .isAvailable()) {
            throw new Exception("Not available yet");
        }
        int count = 0;
        int result = beginMmsConnectivity(mConnMgr);
        if (result != PhoneEx.APN_ALREADY_ACTIVE) {
            NetworkInfo info = mConnMgr
                    .getNetworkInfo(ConnectivityManager.TYPE_MOBILE_MMS);
            while (!info.isConnected()) {
                Thread.sleep(1500);
                info = mConnMgr
                        .getNetworkInfo(ConnectivityManager.TYPE_MOBILE_MMS);
                Log.d(">>>", "Waiting for CONNECTED: state=" + info.getState());
                if (count++ > 5)
                    throw new Exception("Failed to connect");
            }
        }
        Thread.sleep(1500);
    }
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!