2012-08-27 45 views
5

我的應用應該打開移動網絡設置活動。Android 4.1中的移動網絡設置

java.lang.SecurityException: Permission Denial: starting Intent { act=android.settings.DATA_ROAMING_SETTINGS cmp=com.android.phone/.Settings } from ProcessRecord{41b83198 ... 

任何想法:除了搭載Android 4.1的設備崩潰後

Intent intent = new Intent(android.provider.Settings.ACTION_DATA_ROAMING_SETTINGS); 
final ComponentName cName = new ComponentName("com.android.phone", "com.android.phone.Settings"); 
intent.setComponent(cName); 
startActivity(intent); 

堆棧跟蹤要打開的崩潰嘗試後設置,一切工作正常?這可能是因爲表現?

UPDATE:

看來,這個問題在這裏得到解決: Android - Mobile network settings menu (Jelly Bean)

的是要改變 「com.android.phone.Settings」 到 「com.android.phone.MobileNetworkSettings」

+0

你測試過這個設備,因爲[在某些情況下,一個匹配的Activity可能不存在,因此請確保你的防護措施](http://developer.android .com/reference/android/provider/Settings.html#ACTION_DATA_ROAMING_SETTINGS) – Andrei

+0

問題發現在Nexus S上 – Alex

回答

7

我認爲你必須嘗試

Intent intent = new Intent(); 
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
intent.setAction(android.provider.Settings.ACTION_DATA_ROAMING_SETTINGS); 
startActivity(intent); 

這件事的是Android 4.1.2爲我工作, 可能是他們在4.1.2中修復了這個問題