requestRouteToHost(int networkType, int hostAddress)
This method was deprecated in API level 21. Deprecated in favor of the
requestNetwork(NetworkRequest, NetworkCallback)
bindProcessToNetwork(Network) and getSocketFactory()
API. In M, and above, this method is unsupported and will throw UnsupportedOperationException if called. Reference of Android Docs
Android official site dont have any implementation as a alternative of requestRouteToHost(int networkType, int hostAddress)
I google and found this
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
ConnectivityManager connMgr = (ConnectivityManager) this
.getSystemService(Context.CONNECTIVITY_SERVICE);
NetworkRequest.Builder builder = new NetworkRequest.Builder();
//what Capability i have to add for
**requestRouteToHost(int networkType, int hostAddress)** implementation.
builder.addCapability(NetworkCapabilities.NET_CAPABILITY_MMS);
builder.addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR);
NetworkRequest networkRequest = builder.build();
connMgr.requestNetwork(networkRequest, new ConnectivityManager.NetworkCallback() {
@Override
public void onAvailable(Network network) {
super.onAvailable(network);
// sendNormalMms();
try {
int y = Integer.parseInt(apns.get(0).MMSPort);
HttpUtils.httpConnection(mContext, 4444L,
apns.get(0).MMSCenterUrl, bytesToSend,
HttpUtils.HTTP_POST_METHOD,
!TextUtils.isEmpty(apns.get(0).MMSProxy),
apns.get(0).MMSProxy, y);
} catch (Exception e) {
}
}
});
Issue: Connectivity is not getting ready to send MMS
curser is not getting on OnAvalabile();
Is this the right to ready decive to send MMS?
Found Issue:
Mobile data is trun off thats why state is not getting ready to send MMS.