require being set as the default SMS app on QPlus too
This commit is contained in:
parent
4273ff0b22
commit
3637afc0bb
|
@ -1,6 +1,8 @@
|
||||||
package com.simplemobiletools.smsmessenger.activities
|
package com.simplemobiletools.smsmessenger.activities
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.app.Activity
|
import android.app.Activity
|
||||||
|
import android.app.role.RoleManager
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.provider.Telephony
|
import android.provider.Telephony
|
||||||
|
@ -27,6 +29,7 @@ class MainActivity : SimpleActivity() {
|
||||||
private var storedTextColor = 0
|
private var storedTextColor = 0
|
||||||
private val MAKE_DEFAULT_APP_REQUEST = 1
|
private val MAKE_DEFAULT_APP_REQUEST = 1
|
||||||
|
|
||||||
|
@SuppressLint("InlinedApi")
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
super.onCreate(savedInstanceState)
|
super.onCreate(savedInstanceState)
|
||||||
setContentView(R.layout.activity_main)
|
setContentView(R.layout.activity_main)
|
||||||
|
@ -36,11 +39,17 @@ class MainActivity : SimpleActivity() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Telephony.Sms.getDefaultSmsPackage(this) == packageName) {
|
if (isQPlus()) {
|
||||||
askPermissions()
|
val roleManager = getSystemService(RoleManager::class.java)
|
||||||
|
if (roleManager!!.isRoleHeld(RoleManager.ROLE_SMS)) {
|
||||||
|
askPermissions()
|
||||||
|
} else {
|
||||||
|
val intent = roleManager.createRequestRoleIntent(RoleManager.ROLE_SMS)
|
||||||
|
startActivityForResult(intent, MAKE_DEFAULT_APP_REQUEST)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if (isQPlus()) {
|
if (Telephony.Sms.getDefaultSmsPackage(this) == packageName) {
|
||||||
|
askPermissions()
|
||||||
} else {
|
} else {
|
||||||
val intent = Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT)
|
val intent = Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT)
|
||||||
intent.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME, packageName)
|
intent.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME, packageName)
|
||||||
|
|
Loading…
Reference in New Issue