Search code examples
javaandroidnetwork-programmingandroid-4.4-kitkatapn

Unable to connect to IMS apn from my application


I need to connect to IMS apn from my application. When i try to connect to the IMS apn it connects and disconnects on my phone, same happens even with MMS on kitkat. Can someone help me in resolving this issue. This is code is from my fragment inside oncreate

private string REQUIRED_FEATURE = "enableIMS"; # also tried with "enableMMS"

ConnectionManager mConMgr = ((ConnectivityManager)getActivity()).getSystemSerivce(Context.CONNECTIVITY_SERVICE);
int result =.stopUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE, REQUIRED_FEATURE);                     

Log.d(TAG, "we got connected result id  as  : " + result);

NetworkInfo ntInfo = mConMgr.getActiveNetworkInfo();

if (ntInfo != null)
    Log.d(TAG, "we now network what we requested :: " + ntInfo.getExtraInfo()
                + " ::  network connection");

After disconnecting from this apn it hops back to default apn. starting from connection to hoping onto default happens within a minute.

Looking into my log i found these states: Connected, disconnected, and reasons are connected , linkpropertieschanged, datadisabled. Basically trying to connect to ims apn and need to send data


Solution

  • If connection is going down. Use startUsingNetworkFeature for enableIMS every 50 secs so the IMS is up always, at the end of it you can send data out.