2011-02-28 49 views
3

如果您通過禁用3G(點擊F8)來訪問瀏覽器,那麼瀏覽器仍然可以正常工作。 我想在我的應用程序中使用類似的功能,我如何在我的應用程序中實現相同的功能。如何在Android中激活掛起的3G連接

目前我們使用下面的代碼在我們的應用程序:

protected boolean isNetworkCoverageAvailable() 
{ 
    boolean result = false; 
    Context oContext = AndroidContext.getContext(); 
    ConnectivityManager connMgr = (ConnectivityManager) oContext.getSystemService(Context.CONNECTIVITY_SERVICE); 
    NetworkInfo wifi = connMgr.getNetworkInfo(ConnectivityManager.TYPE_WIFI); 
    NetworkInfo mobile = connMgr.getNetworkInfo(ConnectivityManager.TYPE_MOBILE); 

    if(wifi.isConnected() == true){ 
     result = true; 
    } else if (mobile.isConnectedOrConnecting() == true){ 
     result = true; 
    } else { 
     result = oMgr.getDataState() == TelephonyManager.DATA_CONNECTED; 
    } 
    Log.d(TAG, "Result: " + result + ""); 
    return result; 
} 

應用程序是工作的Wi-Fi和3G功能,但我想應用程序需要激活3G,如果自動3G是因爲unusuability暫停設備。

我該如何在Android中執行此操作?

回答

0

我不認爲你可以以編程方式啓用3G。 用戶選擇禁用或啓用它。

你可以做的是要求用戶啓用WIFI或3G,並將他們引導到設置屏幕? 我想我以前見過這樣的應用程序。