Android Studio: 我的短信应用不是默认短信应用选项之一。

huangapple go评论80阅读模式
英文:

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:

    &lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
package=&quot;com.example.imessages&quot;&gt;
&lt;uses-permission android:name=&quot;android.permission.INTERNET&quot; /&gt;
&lt;uses-permission android:name=&quot;android.permission.SEND_SMS&quot; /&gt;
&lt;uses-permission android:name=&quot;android.permission.RESPOND_VIA_MESSAGE&quot; /&gt;
&lt;uses-permission android:name=&quot;android.permission.WAP_PUSH_DELIVER&quot; /&gt;
&lt;uses-permission android:name=&quot;android.permission.RECEIVE_MMS&quot; /&gt;
&lt;uses-permission android:name=&quot;android.permission.RECEIVE_SMS&quot; /&gt;
&lt;uses-permission android:name=&quot;android.permission.READ_CONTACTS&quot; /&gt;
&lt;uses-permission android:name=&quot;android.permission.READ_SMS&quot; /&gt;
&lt;uses-permission android:name=&quot;android.permission.WRITE_SMS&quot; /&gt;
&lt;uses-permission android:name=&quot;android.permission.RECEIVE_MMS&quot; /&gt;
&lt;uses-permission android:name=&quot;android.permission.RECEIVE_BOOT_COMPLETED&quot;/&gt;
&lt;application
android:allowBackup=&quot;false&quot;
android:icon=&quot;@mipmap/ic_launcher&quot;
android:label=&quot;@string/app_name&quot;
android:roundIcon=&quot;@mipmap/ic_launcher_round&quot;
android:supportsRtl=&quot;true&quot;
android:theme=&quot;@style/AppTheme&quot;&gt;
&lt;activity android:name=&quot;.editNameAndPhoto_activity&quot; /&gt;
&lt;receiver
android:name=&quot;.MySMSReceiver&quot;
android:enabled=&quot;true&quot;
android:exported=&quot;true&quot;
android:permission=&quot;android.permission.BROADCAST_SMS&quot;&gt;
&lt;intent-filter android:priority=&quot;999&quot;&gt;
&lt;action android:name=&quot;android.provider.Telephony.SMS_RECEIVED&quot; /&gt;
&lt;action android:name=&quot;android.permission.BROADCAST_SMS&quot; /&gt;
&lt;/intent-filter&gt;
&lt;/receiver&gt;
&lt;receiver android:name=&quot;.MyMMSReceiver&quot;
android:exported=&quot;true&quot;
android:permission=&quot;android:permission.BROADCAST_WAP_PUSH&quot;&gt;
&lt;intent-filter android:priority=&quot;999&quot; &gt;
&lt;action android:name=&quot;android.provider.Telephony.WAP_PUSH_DELIVER&quot; /&gt;
&lt;data android:mimeType=&quot;application/vnd.wap.mms-message&quot; /&gt;
&lt;/intent-filter&gt;
&lt;/receiver&gt;
&lt;service
android:name=&quot;.QuickResponseService&quot;
android:exported=&quot;true&quot;
android:permission=&quot;android.permission.SEND_RESPOND_VIA_MESSAGE&quot;&gt;
&lt;intent-filter&gt;
&lt;category android:name=&quot;android.intent.category.DEFAULT&quot; /&gt;
&lt;action android:name=&quot;android.intent.action.RESPOND_VIA_MESSAGE&quot; /&gt;
&lt;data android:scheme=&quot;sms&quot; /&gt;
&lt;data android:scheme=&quot;smsto&quot; /&gt;
&lt;data android:scheme=&quot;mms&quot; /&gt;
&lt;data android:scheme=&quot;mmsto&quot; /&gt;
&lt;/intent-filter&gt;
&lt;/service&gt;
&lt;activity android:name=&quot;.Messages&quot; &gt;
&lt;intent-filter&gt;
&lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;
&lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;
&lt;action android:name=&quot;android.intent.action.SEND&quot; /&gt;
&lt;action android:name=&quot;android.intent.action.SENDTO&quot; /&gt;
&lt;category android:name=&quot;android.intent.category.DEFAULT&quot; /&gt;
&lt;category android:name=&quot;android.intent.category.BROWSABLE&quot; /&gt;
&lt;data android:scheme=&quot;sms&quot; /&gt;
&lt;data android:scheme=&quot;smsto&quot; /&gt;
&lt;data android:scheme=&quot;mms&quot; /&gt;
&lt;data android:scheme=&quot;mmsto&quot; /&gt;
&lt;/intent-filter&gt;
&lt;/activity&gt;
&lt;activity android:name=&quot;.MainActivity&quot; /&gt;
&lt;meta-data
android:name=&quot;preloaded_fonts&quot;
android:resource=&quot;@array/preloaded_fonts&quot; /&gt;
&lt;/application&gt;
&lt;/manifest&gt;

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 = &quot;true&quot; and enabled = &quot;true&quot; 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:

&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
package=&quot;com.example.imessages&quot;&gt;
&lt;uses-permission android:name=&quot;android.permission.INTERNET&quot; /&gt;
&lt;uses-permission android:name=&quot;android.permission.SEND_SMS&quot; /&gt;
&lt;uses-permission android:name=&quot;android.permission.RESPOND_VIA_MESSAGE&quot; /&gt;
&lt;uses-permission android:name=&quot;android.permission.WAP_PUSH_DELIVER&quot; /&gt;
&lt;uses-permission android:name=&quot;android.permission.RECEIVE_MMS&quot; /&gt;
&lt;uses-permission android:name=&quot;android.permission.RECEIVE_SMS&quot; /&gt;
&lt;uses-permission android:name=&quot;android.permission.READ_CONTACTS&quot; /&gt;
&lt;uses-permission android:name=&quot;android.permission.READ_SMS&quot; /&gt;
&lt;uses-permission android:name=&quot;android.permission.WRITE_SMS&quot; /&gt;
&lt;uses-permission android:name=&quot;android.permission.RECEIVE_MMS&quot; /&gt;
&lt;uses-permission android:name=&quot;android.permission.RECEIVE_BOOT_COMPLETED&quot;/&gt;
&lt;application
android:allowBackup=&quot;false&quot;
android:icon=&quot;@mipmap/ic_launcher&quot;
android:label=&quot;@string/app_name&quot;
android:roundIcon=&quot;@mipmap/ic_launcher_round&quot;
android:supportsRtl=&quot;true&quot;
android:theme=&quot;@style/AppTheme&quot;&gt;
&lt;activity android:name=&quot;.editNameAndPhoto_activity&quot; /&gt;
&lt;receiver
android:name=&quot;.MySMSReceiver&quot;
android:enabled=&quot;true&quot;
android:exported=&quot;true&quot;
android:permission=&quot;android.permission.BROADCAST_SMS&quot;&gt;
&lt;intent-filter android:priority=&quot;999&quot;&gt;
&lt;action android:name=&quot;android.provider.Telephony.SMS_DELIVER&quot; /&gt;
&lt;action android:name=&quot;android.permission.BROADCAST_SMS&quot; /&gt;
&lt;/intent-filter&gt;
&lt;/receiver&gt;
&lt;receiver android:name=&quot;.MyMMSReceiver&quot;
android:exported=&quot;true&quot;
android:permission=&quot;android.permission.BROADCAST_WAP_PUSH&quot;&gt;
&lt;intent-filter android:priority=&quot;999&quot; &gt;
&lt;action android:name=&quot;android.provider.Telephony.WAP_PUSH_DELIVER&quot; /&gt;
&lt;data android:mimeType=&quot;application/vnd.wap.mms-message&quot; /&gt;
&lt;/intent-filter&gt;
&lt;/receiver&gt;
&lt;service
android:name=&quot;.QuickResponseService&quot;
android:permission=&quot;android.permission.SEND_RESPOND_VIA_MESSAGE&quot;&gt;
&lt;intent-filter&gt;
&lt;action android:name=&quot;android.intent.action.RESPOND_VIA_MESSAGE&quot; /&gt;
&lt;category android:name=&quot;android.intent.category.DEFAULT&quot; /&gt;
&lt;data android:scheme=&quot;sms&quot; /&gt;
&lt;data android:scheme=&quot;smsto&quot; /&gt;
&lt;data android:scheme=&quot;mms&quot; /&gt;
&lt;data android:scheme=&quot;mmsto&quot; /&gt;
&lt;/intent-filter&gt;
&lt;/service&gt;
&lt;activity android:name=&quot;.Messages&quot; &gt;
&lt;intent-filter&gt;
&lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;
&lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;
&lt;/intent-filter&gt;
&lt;intent-filter&gt;
&lt;action android:name=&quot;android.intent.action.SEND&quot; /&gt;
&lt;action android:name=&quot;android.intent.action.SENDTO&quot; /&gt;
&lt;category android:name=&quot;android.intent.category.DEFAULT&quot; /&gt;
&lt;category android:name=&quot;android.intent.category.BROWSABLE&quot; /&gt;
&lt;data android:scheme=&quot;sms&quot; /&gt;
&lt;data android:scheme=&quot;smsto&quot; /&gt;
&lt;data android:scheme=&quot;mms&quot; /&gt;
&lt;data android:scheme=&quot;mmsto&quot; /&gt;
&lt;/intent-filter&gt;
&lt;/activity&gt;
&lt;activity android:name=&quot;.MainActivity&quot; /&gt;
&lt;meta-data
android:name=&quot;preloaded_fonts&quot;
android:resource=&quot;@array/preloaded_fonts&quot; /&gt;
&lt;/application&gt;
&lt;/manifest&gt;

huangapple
  • 本文由 发表于 2020年8月19日 02:34:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/63474680.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定