Open themelisx opened 7 years ago
Are there any solutions that don't rely on reflection?
This is a complete solution that works to all Android versions
I have tried this out, and it doesn't seem to work, at least on my Pixel. How are you testing and can you tell me the results you are getting?
06-14 16:24:59.994 13294-13294/com.klinker.android.send_message.sample W/System.err: java.lang.reflect.InvocationTargetException
06-14 16:24:59.995 13294-13294/com.klinker.android.send_message.sample W/System.err: at java.lang.reflect.Method.invoke(Native Method)
06-14 16:24:59.996 13294-13294/com.klinker.android.send_message.sample W/System.err: at com.klinker.android.send_message.Utils.setMobileDataEnabled(Utils.java:223)
06-14 16:24:59.996 13294-13294/com.klinker.android.send_message.sample W/System.err: at com.klinker.android.messaging_sample.MainActivity.onCreate(MainActivity.java:73)
06-14 16:24:59.996 13294-13294/com.klinker.android.send_message.sample W/System.err: at android.app.Activity.performCreate(Activity.java:6982)
06-14 16:24:59.997 13294-13294/com.klinker.android.send_message.sample W/System.err: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)
06-14 16:24:59.997 13294-13294/com.klinker.android.send_message.sample W/System.err: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)
06-14 16:24:59.997 13294-13294/com.klinker.android.send_message.sample W/System.err: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)
06-14 16:24:59.998 13294-13294/com.klinker.android.send_message.sample W/System.err: at android.app.ActivityThread.-wrap11(Unknown Source:0)
06-14 16:24:59.998 13294-13294/com.klinker.android.send_message.sample W/System.err: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1593)
06-14 16:24:59.998 13294-13294/com.klinker.android.send_message.sample W/System.err: at android.os.Handler.dispatchMessage(Handler.java:105)
06-14 16:24:59.999 13294-13294/com.klinker.android.send_message.sample W/System.err: at android.os.Looper.loop(Looper.java:164)
06-14 16:24:59.999 13294-13294/com.klinker.android.send_message.sample W/System.err: at android.app.ActivityThread.main(ActivityThread.java:6541)
06-14 16:24:59.999 13294-13294/com.klinker.android.send_message.sample W/System.err: at java.lang.reflect.Method.invoke(Native Method)
06-14 16:25:00.001 13294-13294/com.klinker.android.send_message.sample W/System.err: at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240)
06-14 16:25:00.001 13294-13294/com.klinker.android.send_message.sample W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)
06-14 16:25:00.002 13294-13294/com.klinker.android.send_message.sample W/System.err: Caused by: java.lang.SecurityException: No Carrier Privilege.
06-14 16:25:00.002 13294-13294/com.klinker.android.send_message.sample W/System.err: at android.os.Parcel.readException(Parcel.java:1948)
06-14 16:25:00.002 13294-13294/com.klinker.android.send_message.sample W/System.err: at android.os.Parcel.readException(Parcel.java:1894)
06-14 16:25:00.002 13294-13294/com.klinker.android.send_message.sample W/System.err: at com.android.internal.telephony.ITelephony$Stub$Proxy.setDataEnabled(ITelephony.java:4094)
06-14 16:25:00.002 13294-13294/com.klinker.android.send_message.sample W/System.err: at android.telephony.TelephonyManager.setDataEnabled(TelephonyManager.java:5385)
06-14 16:25:00.002 13294-13294/com.klinker.android.send_message.sample W/System.err: at android.telephony.TelephonyManager.setDataEnabled(TelephonyManager.java:5375)
06-14 16:25:00.002 13294-13294/com.klinker.android.send_message.sample W/System.err: ... 15 more
Maybe at Android 6.+ works only if the app is at priv-app (system app). Check also the menifest permissions
Even if app is system, fails to enable data to receive MMS. Here is the solution: