List of usage examples for android.net ConnectivityManager TYPE_MOBILE_MMS
int TYPE_MOBILE_MMS
To view the source code for android.net ConnectivityManager TYPE_MOBILE_MMS.
Click Source Link
From source file:com.moez.QKSMS.mmssms.Transaction.java
private void trySending(final APN apns, final byte[] bytesToSend, final int numRetries) { try {/*w w w .jav a 2 s . c o m*/ IntentFilter filter = new IntentFilter(); filter.addAction(ProgressCallbackEntity.PROGRESS_STATUS_ACTION); BroadcastReceiver receiver = new BroadcastReceiver() { @Override public void onReceive(Context context, Intent intent) { int progress = intent.getIntExtra("progress", -3); if (LOCAL_LOGV) Log.v(TAG, "progress: " + progress); // send progress broadcast to update ui if desired... Intent progressIntent = new Intent(MMS_PROGRESS); progressIntent.putExtra("progress", progress); context.sendBroadcast(progressIntent); if (progress == ProgressCallbackEntity.PROGRESS_COMPLETE) { if (saveMessage) { Cursor query = context.getContentResolver().query(Uri.parse("content://mms"), new String[] { "_id" }, null, null, "date desc"); if (query != null && query.moveToFirst()) { String id = query.getString(query.getColumnIndex("_id")); query.close(); // move to the sent box ContentValues values = new ContentValues(); values.put("msg_box", 2); String where = "_id" + " = '" + id + "'"; context.getContentResolver().update(Uri.parse("content://mms"), values, where, null); } } context.sendBroadcast(new Intent(REFRESH)); try { context.unregisterReceiver(this); } catch (Exception e) { /* Receiver not registered */ } // give everything time to finish up, may help the abort being shown after the progress is already 100 new Handler().postDelayed(new Runnable() { @Override public void run() { mConnMgr.stopUsingNetworkFeature(ConnectivityManager.TYPE_MOBILE_MMS, "enableMMS"); if (settings.getWifiMmsFix()) { reinstateWifi(); } } }, 1000); } else if (progress == ProgressCallbackEntity.PROGRESS_ABORT) { // This seems to get called only after the progress has reached 100 and then something else goes wrong, so here we will try and send again and see if it works if (LOCAL_LOGV) Log.v(TAG, "sending aborted for some reason..."); context.unregisterReceiver(this); if (numRetries < NUM_RETRIES) { // sleep and try again in three seconds to see if that give wifi and mobile data a chance to toggle in time try { Thread.sleep(3000); } catch (Exception f) { } if (settings.getWifiMmsFix()) { sendMMS(bytesToSend); } else { sendMMSWiFi(bytesToSend); } } else { markMmsFailed(); } } } }; context.registerReceiver(receiver, filter); // This is where the actual post request is made to send the bytes we previously created through the given apns if (LOCAL_LOGV) Log.v(TAG, "attempt: " + numRetries); Utils.ensureRouteToHost(context, apns.MMSCenterUrl, apns.MMSProxy); HttpUtils.httpConnection(context, 4444L, apns.MMSCenterUrl, bytesToSend, HttpUtils.HTTP_POST_METHOD, !TextUtils.isEmpty(apns.MMSProxy), apns.MMSProxy, Integer.parseInt(apns.MMSPort)); } catch (IOException e) { if (LOCAL_LOGV) Log.v(TAG, "some type of error happened when actually sending maybe?"); Log.e(TAG, "exception thrown", e); if (numRetries < NUM_RETRIES) { // sleep and try again in three seconds to see if that give wifi and mobile data a chance to toggle in time try { Thread.sleep(3000); } catch (Exception f) { } trySending(apns, bytesToSend, numRetries + 1); } else { markMmsFailed(); } } }
From source file:com.ubiLive.GameCloud.Browser.WebBrowser.java
private void processNetworkType(Intent intent, Context context) { int netType;//from w w w . j a v a 2 s. com int netSubtype; int networkType; boolean isConnected; String reloadUrl; DebugLog.d(TAG, "processNetworkType() enter"); NetworkInfo netInfo = Utils.getCurNetworkInfo(context); if (netInfo == null || netInfo.isAvailable() == false) { DebugLog.d(TAG, "getCurNetworkInfo() is null"); netInfo = (NetworkInfo) intent.getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO); } if (netInfo == null || netInfo.isAvailable() == false) { DebugLog.d(TAG, "getCurNetworkInfo() netInfo is null line1383"); if (mbNetworIsConnect != false) { mbNetworIsConnect = false; reloadUrl = GameInfo.getErrorUrl(); reload(reloadUrl); } Utils.setNetworkType(Constants.NETWORKTYPE_NONE); return; } netType = netInfo.getType(); netSubtype = netInfo.getSubtype(); isConnected = netInfo.isConnected(); DebugLog.e(TAG, "======processNetworkType nettype = " + netType + ",netSubtype = " + netSubtype + ",isConnect = " + isConnected); switch (netType) { case ConnectivityManager.TYPE_MOBILE_SUPL: case ConnectivityManager.TYPE_MOBILE_MMS: case ConnectivityManager.TYPE_MOBILE_HIPRI: case ConnectivityManager.TYPE_MOBILE_DUN: case ConnectivityManager.TYPE_MOBILE: DebugLog.d(TAG, "processNetworkType ConnectivityManager.TYPE_MOBILE netSubtype=" + netSubtype); if (netSubtype == TelephonyManager.NETWORK_TYPE_LTE) {//4 DebugLog.d(TAG, "processNetworkType ConnectivityManager.TYPE_MOBILE 4G"); networkType = Constants.NETWORKTYPE_LTE; } else {//3 DebugLog.d(TAG, "processNetworkType ConnectivityManager.TYPE_MOBILE 3G"); networkType = Constants.NETWORKTYPE_3G; } break; case ConnectivityManager.TYPE_WIFI: DebugLog.d(TAG, "processNetworkType ConnectivityManager.TYPE_WIFI"); networkType = Constants.NETWORKTYPE_WIFI; break; case ConnectivityManager.TYPE_ETHERNET: DebugLog.d(TAG, "processNetworkType ConnectivityManager.TYPE_ETHERNET"); networkType = Constants.NETWORKTYPE_ETHERNET; break; default: DebugLog.d(TAG, "other network status"); networkType = Constants.NETWORKTYPE_OTHERS; break; } DebugLog.e(TAG, "======processNetworkType nettype = " + netType + ",netSubtype = " + netSubtype + ",isConnect = " + isConnected + ",mbNetworIsConnect = " + mbNetworIsConnect); if (isConnected) { reloadUrl = Utils.checkUrl(GameInfo.DEFAULT_URL); Utils.setNetworkType(networkType); // Utils.setNetworkType(Constants.NETWORKTYPE_WIFI);//temp change } else { reloadUrl = GameInfo.getErrorUrl(); Utils.setNetworkType(Constants.NETWORKTYPE_NONE); } // if((networkType == Constants.NETWORKTYPE_WIFI || networkType == Constants.NETWORKTYPE_LTE) && mbNetworIsConnect != isConnected){ if (mbNetworIsConnect != isConnected) { mbNetworIsConnect = isConnected; reload(reloadUrl); DebugLog.d(TAG, "Notify reload finish"); } }
From source file:com.shinymayhem.radiopresets.ServiceRadioPlayer.java
protected int getConnectionType() { int newState = mNetworkInfo.getType(); if (LOCAL_LOGV) { String str = ""; switch (newState) { case ConnectivityManager.TYPE_WIFI: str += "wifi"; break; case ConnectivityManager.TYPE_MOBILE: str += "mobile"; break; case ConnectivityManager.TYPE_MOBILE_DUN: str += "mobile-dun"; break; case ConnectivityManager.TYPE_MOBILE_HIPRI: str += "moblie-hipri"; break; case ConnectivityManager.TYPE_MOBILE_MMS: str += "mobile-mms"; break; case ConnectivityManager.TYPE_MOBILE_SUPL: str += "mobile-supl"; break; case ConnectivityManager.TYPE_WIMAX: str += "wimax"; break; case ConnectivityManager.TYPE_ETHERNET: str += "ethernet"; break; case ConnectivityManager.TYPE_BLUETOOTH: str += "bluetooth"; break; case ConnectivityManager.TYPE_DUMMY: str += "dummy"; break; }// w w w . ja v a2s .c o m str += " detected"; log(str, "v"); } return newState; }
From source file:com.chen.emailsync.SyncManager.java
/** * Taken from ConnectivityManager using public constants *///from w w w .j a va 2 s . com public static boolean isNetworkTypeMobile(int networkType) { switch (networkType) { case ConnectivityManager.TYPE_MOBILE: case ConnectivityManager.TYPE_MOBILE_MMS: case ConnectivityManager.TYPE_MOBILE_SUPL: case ConnectivityManager.TYPE_MOBILE_DUN: case ConnectivityManager.TYPE_MOBILE_HIPRI: return true; default: return false; } }