Android permission doesn't work even if I have declared it -
i'm trying write code send sms android app, when try send sms sends me error:
09-17 18:37:29.974 12847-12847/**.**.****e/androidruntime﹕ fatal exception: main process: **.**.****, pid: 12847 java.lang.securityexception: sending sms message: uid 10092 not have android.permission.send_sms. @ android.os.parcel.readexception(parcel.java:1599) @ android.os.parcel.readexception(parcel.java:1552) @ com.android.internal.telephony.isms$stub$proxy.sendtextforsubscriber(isms.java:768) @ android.telephony.smsmanager.sendtextmessageinternal(smsmanager.java:310) @ android.telephony.smsmanager.sendtextmessage(smsmanager.java:293) @ **.**.****.mainactivity$3.onclick(mainactivity.java:70) @ android.view.view.performclick(view.java:5198) @ android.view.view$performclick.run(view.java:21147) @ android.os.handler.handlecallback(handler.java:739) @ android.os.handler.dispatchmessage(handler.java:95) @ android.os.looper.loop(looper.java:148) @ android.app.activitythread.main(activitythread.java:5417) @ java.lang.reflect.method.invoke(native method) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:726) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:616)
i checked have permissions in manifest, follows:
<?xml version="1.0" encoding="utf-8"?>
<uses-permission android:name="android.permission.send_sms"/> <uses-feature android:name="android.hardware.telephony" android:required="true"/> <application android:exported="true" android:allowbackup="true" android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/apptheme"> <activity android:name=".mainactivity" android:label="@string/app_name" android:screenorientation="portrait"> <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> </application>
i searched internet errors <uses-permission/>
syntax, me please?
(the following extracted a blog post of mine this)
the big reason not getting permission nowadays because project has targetsdkversion
of 23 or higher, , permission requesting "dangerous". in android 6.0, includes:
access_coarse_location
access_fine_location
add_voicemail
body_sensors
call_phone
camera
get_accounts
process_outgoing_calls
read_calendar
read_call_log
read_cell_broadcasts
read_contacts
read_external_storage
read_phone_state
read_sms
receive_mms
receive_sms
receive_wap_push
record_audio
send_sms
use_sip
write_calendar
write_call_log
write_contacts
write_external_storage
for these permissions, not targetsdkversion
23+ app need have <uses-permission>
element(s), have ask permissions @ runtime user on android 6.0+ devices, using methods checkselfpermission()
, requestpermissions()
.
as temporary workaround, drop targetsdkversion
below 23.
however, eventually, have reason want targetsdkversion
23 or higher. @ time, need adjust app use new runtime permission system. android documentation has a page dedicated topic.
Comments
Post a Comment