简体   繁体   English

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

[英]Android Studio: my sms app is not one of the options for default SMS app

I'm new to android app development so bear with me.我是 android 应用程序开发的新手,请多多包涵。

I've made a SMS app and are now trying to give the user the option to make the app the default SMS-app.我已经制作了一个 SMS 应用程序,现在正试图让用户选择使该应用程序成为默认的 SMS 应用程序。 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.我读过该应用程序应该能够完成标准 SMS 应用程序可以做的所有事情,然后才能成为默认的 SMS 应用程序。 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.我还制作了用于接收彩信的 broadcastreceivers 和用于快速响应的服务。 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.这些除了存在之外什么都不做,所以我的手机认为该应用程序能够完成 SMS 应用程序应该做的所有事情。

I've made it so when the user opens the app, the app checks if the app is the default SMS-app.我已经这样做了,当用户打开应用程序时,应用程序会检查该应用程序是否是默认的 SMS 应用程序。 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.问题是我的应用程序没有显示为默认 SMS 应用程序的选项之一。 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.我认为这是因为手机不认为该应用程序能够完成 SMS 应用程序需要做的所有事情,因此没有将其显示为选项之一。

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.我又是新手,所以我已经将所有内容都包含在清单中,这将使我的应用程序看起来像是一个 SMS 应用程序。 There might be some stuff in there that shouldn't be there.那里可能有一些不应该在那里的东西。 Thanks in advance.提前致谢。

So I managed to fix it.所以我设法修复了它。 Thanks for your help.谢谢你的帮助。 I think I know what fixed it (thanks Pawel) here's my explanation:我想我知道是什么修复了它(感谢 Pawel)这是我的解释:

I removed the exported = "true" and enabled = "true" since i found out that they are irrelevant, at least for my project.我删除了exported = "true"enabled = "true"因为我发现它们是不相关的,至少对于我的项目是这样。 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.我确实将.MySMSReceiverSMS_RECEIVED更改为SMS_DELIVER ,这是 Pawel 告诉我的。 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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM