我的 logcat 中出现错误说明:需要 android.permission.onlyusebyphone,我不确定为什么会这样。我设置了正确的权限(如下所示),并且我了解您无法在 ICS+ 中编辑 APN 设置,但您至少应该能够使用以下命令打开 APN 设置菜单:
资源:
} else if (v == mAssistInstrButton) {
// "LET'S DO THIS" Button in final instructions screen for ICS and
// up is selected
Values = getValues();
startActivity(new Intent(Settings.ACTION_APN_SETTINGS));
try {
showNotification();
} catch (SAXException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ParserConfigurationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finish();
日志猫:
09-09 10:31:49.509: E/AndroidRuntime(3007): FATAL EXCEPTION: main
09-09 10:31:49.509: E/AndroidRuntime(3007): java.lang.SecurityException: Permission Denial: starting Intent { act=android.settings.APN_SETTINGS cmp=com.android.settings/.ApnSettings } from ProcessRecord{42a1fa58 3007:com.sample.project.datasettings/u0a84} (pid=3007, uid=10084)
09-09 10:31:49.509: E/AndroidRuntime(3007): at android.os.Parcel.readException(Parcel.java:1425)
09-09 10:31:49.509: E/AndroidRuntime(3007): at android.os.Parcel.readException(Parcel.java:1379)
09-09 10:31:49.509: E/AndroidRuntime(3007): at android.app.ActivityManagerProxy.startActivity(ActivityManagerNative.java:1761)
09-09 10:31:49.509: E/AndroidRuntime(3007): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1411)
09-09 10:31:49.509: E/AndroidRuntime(3007): at android.app.Activity.startActivityForResult(Activity.java:3351)
09-09 10:31:49.509: E/AndroidRuntime(3007): at android.app.Activity.startActivityForResult(Activity.java:3312)
09-09 10:31:49.509: E/AndroidRuntime(3007): at android.app.Activity.startActivity(Activity.java:3522)
09-09 10:31:49.509: E/AndroidRuntime(3007): at android.app.Activity.startActivity(Activity.java:3490)
09-09 10:31:49.509: E/AndroidRuntime(3007): at com.sample.project.datasettings.ConfigFinalActivity.onClick(ConfigFinalActivity.java:199)
09-09 10:31:49.509: E/AndroidRuntime(3007): at android.view.View.performClick(View.java:4084)
09-09 10:31:49.509: E/AndroidRuntime(3007): at android.view.View$PerformClick.run(View.java:16966)
09-09 10:31:49.509: E/AndroidRuntime(3007): at android.os.Handler.handleCallback(Handler.java:615)
09-09 10:31:49.509: E/AndroidRuntime(3007): at android.os.Handler.dispatchMessage(Handler.java:92)
09-09 10:31:49.509: E/AndroidRuntime(3007): at android.os.Looper.loop(Looper.java:137)
09-09 10:31:49.509: E/AndroidRuntime(3007): at android.app.ActivityThread.main(ActivityThread.java:4795)
09-09 10:31:49.509: E/AndroidRuntime(3007): at java.lang.reflect.Method.invokeNative(Native Method)
09-09 10:31:49.509: E/AndroidRuntime(3007): at java.lang.reflect.Method.invoke(Method.java:511)
09-09 10:31:49.509: E/AndroidRuntime(3007): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
09-09 10:31:49.509: E/AndroidRuntime(3007): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
09-09 10:31:49.509: E/AndroidRuntime(3007): at dalvik.system.NativeStart.main(Native Method)
显现:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sample.project.datasettings"
android:versionCode="4"
android:versionName="1.3" >
<uses-permission android:name="android.permission.WRITE_APN_SETTINGS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-feature android:name="android.hardware.telephony" android:required="false" />
<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="17"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<application
android:icon="@drawable/notifications_icon"
android:label="@string/app_name"
android:theme="@android:style/Theme.NoTitleBar" >
<activity
android:name="com.sample.project.datasettings.StartActivity"
android:label="@string/display_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.sample.project.datasettings.UpdateActivity"
android:label="@string/app_name"
android:configChanges="orientation|keyboardHidden|screenSize">
</activity>
<activity
android:name="com.sample.project.datasettings.ConfigFinalActivity"
android:configChanges="orientation">
</activity>
<activity
android:name="com.sample.project.datasettings.MySSLSocketFactory"
android:configChanges="orientation">
</activity>
<activity
android:name="com.sample.project.datasettings.NotificationActivityForMultiProf"
android:theme="@android:style/Theme.NoDisplay" >
</activity>
</application>
</manifest>