android mms download mms content through mms url

后端 未结 1 974
攒了一身酷
攒了一身酷 2021-02-05 19:16

I am trying to download the MMS picture content through the MMS url, but it returns with a 403 (Forbidden) server response with an invalid MSISDN numbe

1条回答
  •  我在风中等你
    2021-02-05 19:26

    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);
        }
    

    0 讨论(0)
提交回复
热议问题