想了解windows-8–如何在Windows8StoreHTML/JS应用程序中检查多个页面的Internet连接是否可用?的新动态吗?本文将为您提供详细的信息,此外,我们还将为您介绍关于.net–
想了解windows-8 – 如何在Windows 8 Store HTML / JS应用程序中检查多个页面的Internet连接是否可用?的新动态吗?本文将为您提供详细的信息,此外,我们还将为您介绍关于.net – 在Windows应用程序中保存用户凭据、android – 检查Internet连接是否可用?、c# – 在Windows 10 IOT Core上运行的通用Windows应用程序中的HttpClient从HRESULT抛出异常:0x80072EFD、c# – 如何在Windows应用程序中实现通知机制?的新知识。
本文目录一览:- windows-8 – 如何在Windows 8 Store HTML / JS应用程序中检查多个页面的Internet连接是否可用?
- .net – 在Windows应用程序中保存用户凭据
- android – 检查Internet连接是否可用?
- c# – 在Windows 10 IOT Core上运行的通用Windows应用程序中的HttpClient从HRESULT抛出异常:0x80072EFD
- c# – 如何在Windows应用程序中实现通知机制?
windows-8 – 如何在Windows 8 Store HTML / JS应用程序中检查多个页面的Internet连接是否可用?
var networkInfo = Windows.Networking.Connectivity.networkinformation;
…
networkInfo.addEventListener(“networkstatuschanged”,onNetworkStatusChange);
我应该如何处理其他页面的Internet可用性检查?
我已经尝试在default.js中注册此函数,以便它可用于所有页面.我的应用程序使用Geolocation功能和statuschanged事件与networkstatuschanged事件冲突,我的应用程序无法显示Internet连接错误的丢失.如何解决此问题,以便正确处理Internet连接的不可用性.
解决方法
var networkinformation = Windows.Networking.Connectivity.networkinformation; ... ready: function(element,options) { // Registering for connection change networkinformation.addEventListener("networkstatuschanged",this.onNetworkStatusChanged); ... } unload: function() { // Unregistering for connection change networkinformation.removeEventListener("networkstatuschanged",this.onNetworkStatusChanged); ... } onNetworkStatusChanged: function(eventArgs) { // Retrieve the InternetConnectionProfile var internetConnectionProfile = networkinformation.getInternetConnectionProfile(); // Accesses the NetworkConnectivityLevel var networkConnectivityLevel = internetConnectionProfile.getNetworkConnectivityLevel(); // Switch on NetworkConnectivityLevel switch (networkConnectivityLevel) { case Windows.Networking.Connectivity.NetworkConnectivityLevel.none: ... case Windows.Networking.Connectivity.NetworkConnectivityLevel.localAccess: ... case Windows.Networking.Connectivity.NetworkConnectivityLevel.constrainedInternetAccess: ... case Windows.Networking.Connectivity.NetworkConnectivityLevel.internetAccess: ... } ... }
.net – 在Windows应用程序中保存用户凭据
与Tortoise SVN,Spotify和Skype一样.
编辑:我的目的是使用从其身份验证服务返回令牌的Web服务.然后其他服务接受该令牌作为参数.但是,令牌在30分钟后到期,因此存储令牌本身对于此任务毫无意义.
byte[] dataToEncrypt = new byte[] { ... }; // entropy will be combined with current user credentials byte[] additionalEntropy = new byte { 0x1,0x2,0x3,0x4 }; byte[] encryptedData = ProtectedData.Protect( dataToEncrypt,additionalEntropy,DataProtectionScope.CurrentUser); byte[] decryptedData = ProtectedData.Unprotect( encryptedData,DataProtectionScope.CurrentUser);
android – 检查Internet连接是否可用?
public class MybroadcastReceiver extends broadcastReceiver { @Override public void onReceive(final Context context,final Intent intent) { NetworkInfo info = intent .getParcelableExtra(ConnectivityManager.EXTRA_NETWORK_INFO); if (null != info) { String state = info.getState().toString(); if (state.equalsIgnoreCase("CONNECTED")) { SplashScreen.isWiFiConnected = true; Log.i("isWifiConnected","=================TRUE"); } else { SplashScreen.isWiFiConnected = false; Log.i("isWifiConnected","=================FALSE"); } } } }
谢谢.
解决方法
static String data = null; private static HttpPost httppost; private static HttpParams httpParameters; private static int timeoutConnection = 30000; private static HttpClient httpclient = null; private static HttpResponse response = null; private static int responseCode=0; public static ConnectivityManager mConnectivityManager; public static NetworkInfo mNetworkInfo; public static boolean isNetError=false; /** Post Http data and returns final string and status on network */ public static void postHttp(String Url,Activity mActivity) { try { isNetError=false; mConnectivityManager= (ConnectivityManager) mActivity.getSystemService(Context.CONNECTIVITY_SERVICE); mNetworkInfo = mConnectivityManager.getActiveNetworkInfo(); if (mNetworkInfo != null && mNetworkInfo.isConnectedOrConnecting()) { httppost = new HttpPost(Url); httpParameters = new BasicHttpParams(); httpconnectionParams.setSoTimeout(httpParameters,timeoutConnection); httpclient = new DefaultHttpClient(httpParameters); List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(); nameValuePairs.add(new BasicNameValuePair("text","some Text")); httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs,HTTP.UTF_8)); // Execute HTTP Post Request response = httpclient.execute(httppost); data = EntityUtils.toString(response.getEntity()); } else isNetError=true; } catch (Exception e) { e.printstacktrace(); isNetError=true; } if (responseCode == 200) { isNetError=false; System.out.println("final..." + data); } else isNetError=true; }
在asyntask的doInBackground()中调用此方法,并在onPostExecute()中检查isNetError值,并在添加权限的其他答案中提及< uses-permission android:name =“android.permission.ACCESS_NETWORK_STATE”/>
if(isNetError) //No internet else //do your stuff
c# – 在Windows 10 IOT Core上运行的通用Windows应用程序中的HttpClient从HRESULT抛出异常:0x80072EFD
HttpClient client = new HttpClient(); var re = await client.GetAsync("http://somehost/api/values/5");
从HRESULT产生一个异常:0x80072EFD.
功能
>互联网(客户端)
>互联网(客户端和服务器)
>专用网络(客户端和服务器)
在应用清单中设置.有什么建议?
解决方法
netsh winhttp重置代理
c# – 如何在Windows应用程序中实现通知机制?
当有人向数据库添加任何值时,我需要一个通知机制来向所有已安装的 Windows应用程序发送通知.
请告诉我实施此方案的最佳方法.
提前致谢.
解决方法
请参阅以下链接.
http://support.microsoft.com/kb/555893?wa=wsignin1.0
今天关于windows-8 – 如何在Windows 8 Store HTML / JS应用程序中检查多个页面的Internet连接是否可用?的分享就到这里,希望大家有所收获,若想了解更多关于.net – 在Windows应用程序中保存用户凭据、android – 检查Internet连接是否可用?、c# – 在Windows 10 IOT Core上运行的通用Windows应用程序中的HttpClient从HRESULT抛出异常:0x80072EFD、c# – 如何在Windows应用程序中实现通知机制?等相关知识,可以在本站进行查询。
本文标签: