英文:
Android Studio: my sms app is not one of the options for default SMS app
问题
我是新手在Android应用开发方面,请耐心等待。
我已经制作了一个短信应用,现在正在尝试为用户提供将该应用设置为默认短信应用的选项。
我已经阅读到,在应用能够成为默认短信应用之前,它应该能够执行标准短信应用的所有功能。
该应用可以执行的功能包括:发送短信、接收和阅读收到的短信。
我还创建了用于接收彩信的广播接收器和用于快速响应的服务。
虽然这些功能没有实际作用,但它们存在是为了让我的手机认为该应用具备了标准短信应用所需的所有功能。
我已经设置了当用户打开应用时,应用会检查应用是否是默认短信应用。如果不是,默认情况下它会询问用户是否要将应用设置为默认。问题是我的应用在默认短信应用选项中并没有显示出来。
我认为这是因为手机认为该应用没有具备标准短信应用所需的所有功能,因此没有将其显示为默认选项之一。
这是我的清单文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.imessages">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.RESPOND_VIA_MESSAGE" />
<uses-permission android:name="android.permission.WAP_PUSH_DELIVER" />
<uses-permission android:name="android.permission.RECEIVE_MMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.WRITE_SMS" />
<uses-permission android:name="android.permission.RECEIVE_MMS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<application
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".editNameAndPhoto_activity" />
<receiver
android:name=".MySMSReceiver"
android:enabled="true"
android:exported="true"
android:permission="android.permission.BROADCAST_SMS">
<intent-filter android:priority="999">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
<action android:name="android.permission.BROADCAST_SMS" />
</intent-filter>
</receiver>
<receiver android:name=".MyMMSReceiver"
android:exported="true"
android:permission="android:permission.BROADCAST_WAP_PUSH">
<intent-filter android:priority="999" >
<action android:name="android.provider.Telephony.WAP_PUSH_DELIVER" />
<data android:mimeType="application/vnd.wap.mms-message" />
</intent-filter>
</receiver>
<service
android:name=".QuickResponseService"
android:exported="true"
android:permission="android.permission.SEND_RESPOND_VIA_MESSAGE">
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.RESPOND_VIA_MESSAGE" />
<data android:scheme="sms" />
<data android:scheme="smsto" />
<data android:scheme="mms" />
<data android:scheme="mmsto" />
</intent-filter>
</service>
<activity android:name=".Messages" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.SENDTO" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="sms" />
<data android:scheme="smsto" />
<data android:scheme="mms" />
<data android:scheme="mmsto" />
</intent-filter>
</activity>
<activity android:name=".MainActivity" />
<meta-data
android:name="preloaded_fonts"
android:resource="@array/preloaded_fonts" />
</application>
</manifest>
再次说明,我对此还是新手,所以我在清单中包含了所有可能让我的应用看起来像是短信应用的内容。其中可能包含一些不应该出现的内容。提前感谢你的帮助。
英文:
I'm new to android app development so bear with me.
I've made a SMS app and are now trying to give the user the option to make the app the default SMS-app.
I've read that the app is supposed to be able to do everything the standard SMS app can before it can become the default SMS-app.
The functions the app can is: send SMS and receive and read incoming SMS.
I've also made the broadcastreceivers for receiving MMS and the service for quick response.
These do not do anything but is there so my phone thinks that the app is capable of everything an SMS app is supposed to do.
I've made it so when the user opens the app, the app checks if the app is the default SMS-app. If not, it will ask the user if the user wants the set the app as default. The problem is that my app isn't showing up as one of the options for default SMS apps.
I think it's because of the phone don't think the app is capable of everything an SMS app needs to do, and therefore isn't showing it as one of the options.
Heres my Manifest file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.imessages">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.RESPOND_VIA_MESSAGE" />
<uses-permission android:name="android.permission.WAP_PUSH_DELIVER" />
<uses-permission android:name="android.permission.RECEIVE_MMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.WRITE_SMS" />
<uses-permission android:name="android.permission.RECEIVE_MMS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<application
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".editNameAndPhoto_activity" />
<receiver
android:name=".MySMSReceiver"
android:enabled="true"
android:exported="true"
android:permission="android.permission.BROADCAST_SMS">
<intent-filter android:priority="999">
<action android:name="android.provider.Telephony.SMS_RECEIVED" />
<action android:name="android.permission.BROADCAST_SMS" />
</intent-filter>
</receiver>
<receiver android:name=".MyMMSReceiver"
android:exported="true"
android:permission="android:permission.BROADCAST_WAP_PUSH">
<intent-filter android:priority="999" >
<action android:name="android.provider.Telephony.WAP_PUSH_DELIVER" />
<data android:mimeType="application/vnd.wap.mms-message" />
</intent-filter>
</receiver>
<service
android:name=".QuickResponseService"
android:exported="true"
android:permission="android.permission.SEND_RESPOND_VIA_MESSAGE">
<intent-filter>
<category android:name="android.intent.category.DEFAULT" />
<action android:name="android.intent.action.RESPOND_VIA_MESSAGE" />
<data android:scheme="sms" />
<data android:scheme="smsto" />
<data android:scheme="mms" />
<data android:scheme="mmsto" />
</intent-filter>
</service>
<activity android:name=".Messages" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.SENDTO" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="sms" />
<data android:scheme="smsto" />
<data android:scheme="mms" />
<data android:scheme="mmsto" />
</intent-filter>
</activity>
<activity android:name=".MainActivity" />
<meta-data
android:name="preloaded_fonts"
android:resource="@array/preloaded_fonts" />
</application>
</manifest>
Again I'm new to this so i've included absolutely everything into the Manifest that will make my app look like it's a SMS app. There might be some stuff in there that shouldn't be there.
Thanks in advance.
答案1
得分: 0
这是我的解释:
我修复了它。感谢你的帮助。我想我知道是什么修复了它(谢谢 Pawel),这是我的解释:
我删除了 exported = "true"
和 enabled = "true"
,因为我发现它们与问题无关,至少对于我的项目来说。这与问题无关。
我将 .MySMSReceiver
的从 SMS_RECEIVED
更改为 SMS_DELIVER
,正如 Pawel 告诉我的那样。一开始我做了这个更改,但它没有起作用,但现在它能正常工作了。肯定是我自己的错误,非常抱歉!
感谢你的帮助!还有,抱歉在你的答案上搞砸了,Pawel。
以下是我的清单文件:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.imessages">
<!-- 权限声明,这里只列出了一部分 -->
<!-- ... -->
<application
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<!-- 活动和接收器声明,这里只列出了一部分 -->
<!-- ... -->
</application>
</manifest>
请注意,我只翻译了你的要求中的内容,保留了代码部分。如果你有任何问题或需要进一步的帮助,请随时告诉我。
英文:
So I managed to fix it.
Thanks for your help.
I think I know what fixed it (thanks Pawel) here's my explanation:
I removed the exported = "true"
and enabled = "true"
since i found out that they are irrelevant, at least for my project. This does not have anything to do with the problem.
I did change the .MySMSReceiver
from SMS_RECEIVED
to SMS_DELIVER
which Pawel told me to. I did and at first it didn't work but now it works. Must have been my mistake sorry!
Thanks for the help! And sorry for messing up on your answer Pawel.
Here's my Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.imessages">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.RESPOND_VIA_MESSAGE" />
<uses-permission android:name="android.permission.WAP_PUSH_DELIVER" />
<uses-permission android:name="android.permission.RECEIVE_MMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.READ_SMS" />
<uses-permission android:name="android.permission.WRITE_SMS" />
<uses-permission android:name="android.permission.RECEIVE_MMS" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<application
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".editNameAndPhoto_activity" />
<receiver
android:name=".MySMSReceiver"
android:enabled="true"
android:exported="true"
android:permission="android.permission.BROADCAST_SMS">
<intent-filter android:priority="999">
<action android:name="android.provider.Telephony.SMS_DELIVER" />
<action android:name="android.permission.BROADCAST_SMS" />
</intent-filter>
</receiver>
<receiver android:name=".MyMMSReceiver"
android:exported="true"
android:permission="android.permission.BROADCAST_WAP_PUSH">
<intent-filter android:priority="999" >
<action android:name="android.provider.Telephony.WAP_PUSH_DELIVER" />
<data android:mimeType="application/vnd.wap.mms-message" />
</intent-filter>
</receiver>
<service
android:name=".QuickResponseService"
android:permission="android.permission.SEND_RESPOND_VIA_MESSAGE">
<intent-filter>
<action android:name="android.intent.action.RESPOND_VIA_MESSAGE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="sms" />
<data android:scheme="smsto" />
<data android:scheme="mms" />
<data android:scheme="mmsto" />
</intent-filter>
</service>
<activity android:name=".Messages" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.SENDTO" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="sms" />
<data android:scheme="smsto" />
<data android:scheme="mms" />
<data android:scheme="mmsto" />
</intent-filter>
</activity>
<activity android:name=".MainActivity" />
<meta-data
android:name="preloaded_fonts"
android:resource="@array/preloaded_fonts" />
</application>
</manifest>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论