如何设置在Android的奇巧我的SMS应用程序的默认?我的、奇巧、应用程序、如何设置

2023-09-13 00:00:02 作者:令我空欢喜

我做了一个Android应用程序的短信中,我发送和接收短信的安卓消息应用程序这样做。现在,我已经把我的目标4.4(Android的奇巧版本),而Android奇巧有新的默认邮件应用程序设置,用户可以同时为消息选择一个应用程序。我跟着从this网站选择选项我的SMS应用程序的默认应用程序,但在设置我的应用程序并没有出现在选择默认的消息应用程序的弹出窗口。

I made an android sms app in which I am sending and receiving sms as android messaging app does so. Now I have set my target to 4.4 (Android KitKat version) but Android KitKat has new "Default Messaging" app settings that user can select one app at a time for messaging. I followed the steps from this site to select option for my sms app as default app but in the settings my app never showed up in the popup of selecting default messaging app.

下面是我的Java code我从GUID使用

Below is my java code I have used from the guid

if( androidOS.contains("4.4") ){


if (! Telephony.Sms.getDefaultSmsPackage(this).equals(myPackageName) ) {

// App is not default.
// Show the "not currently set as the default SMS app" interface

builder = new AlertDialog.Builder(MyConversation.this);
builder.setMessage("Shoot The Messenger is not set as your default messaging app. Do you want to set it default?")
.setCancelable(false)
.setTitle("Alert!")
.setNegativeButton("No", new DialogInterface.OnClickListener() {

@Override
public void onClick(DialogInterface dialog, int which) {


}
})
.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
@TargetApi(19)
public void onClick(DialogInterface dialog, int id) {

Intent intent =
new Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT);

intent.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME,
getPackageName());

startActivity(intent);

}
});
builder.show();


}


}

此外,我在下面加code。在清单文件。

<?xml version="1.0" encoding="utf-8"?>

<uses-sdk
    android:minSdkVersion="8"
    android:targetSdkVersion="19" />


<uses-feature android:name="android.hardware.telephony.gsm"
    android:required="false"/>

<uses-permission android:name="android.permission.READ_CONTACTS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.RECEIVE_SMS" />
<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.WRITE" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.android.alarm.permission.SET_ALARM"/>
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.CALL_PHONE"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.INSTALL_PACKAGES"/>


<application              
    android:allowBackup="true"
    android:icon="@drawable/ic_launcher"
    android:label="@string/app_name"
    android:theme="@style/Theme.NoTitle" >

    <activity
        android:name="coms3.shootmessenger.Mysplash"
        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>


         <intent-filter>
            <action android:name="android.intent.action.SENDTO" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:scheme="sms" />
            <data android:scheme="smsto" />

        </intent-filter>   


    </activity>

    <receiver android:name="coms3.shootmessenger.SmsReceiver" 
        android:permission="android.permission.BROADCAST_SMS" >


        <intent-filter>

            <action android:name="android.provider.Telephony.SMS_DELIVER" />

        </intent-filter>

          <!--  
         <intent-filter android:priority="2147483647" >

            <action android:name="android.provider.Telephony.SMS_RECEIVED" />

        </intent-filter>
       -->
    </receiver>   

    <receiver android:name="com.example.bootreceiver.MyBootReceiver">

        <intent-filter>

            <action android:name="android.intent.action.BOOT_COMPLETED"/>


        </intent-filter>

     </receiver>

     <receiver android:name="coms3.shootmessenger.MMSReceiver"
         android:permission="android.permission.BROADCAST_WAP_PUSH">

          <intent-filter>

            <action android:name="android.provider.Telephony.WAP_PUSH_RECEIVED" />

            <data android:mimeType="application/vnd.wap.mms-message" />

          </intent-filter>

        </receiver>


     <receiver  android:process=":remote" android:name="AlarmManagerBroadcastReceiver"></receiver>
      <receiver  android:process=":remote" android:name="AlarmForPartyMessage"></receiver>
      <receiver  android:process=":remote" android:name="AlarmManagerMail"></receiver>

    <activity
        android:name="coms3.shootmessenger.ActivityFirstList"

        android:windowSoftInputMode="stateHidden" >
    </activity>
     <activity 
         android:name="coms3.shootmessenger.ActivityBase" 

         android:windowSoftInputMode="stateHidden" > 
     </activity> 
    <activity
        android:name="coms3.shootmessenger.SearchTab"
        android:configChanges="keyboardHidden|orientation"
         >
    </activity>
    <activity
        android:name="coms3.shootmessenger.ActivityMail"
        android:windowSoftInputMode="adjustPan"
         >
    </activity>
    <activity
        android:name="coms3.shootmessenger.ActivityScheduldMail"
        android:windowSoftInputMode="adjustPan"
        android:screenOrientation="portrait"
         >
    </activity>
    <activity
        android:name="coms3.shootmessenger.MessageTab" >

    </activity>

    <activity
        android:name="coms3.shootmessenger.SettingsTab"

        android:windowSoftInputMode="stateHidden" >
    </activity>

    <activity
        android:name="coms3.shootmessenger.MyConversation"

        android:windowSoftInputMode="stateHidden" >
    </activity>

    <activity
        android:name="coms3.shootmessenger.ActivityDelayedSending"

        android:windowSoftInputMode="stateHidden" >
    </activity>

    <activity
        android:name="coms3.shootmessenger.ActivityScheduldMessage"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="stateHidden" >
    </activity>
    <activity
        android:name="coms3.shootmessenger.ActivityStealthMode"

        android:windowSoftInputMode="stateHidden" >
    </activity>

    <activity
        android:name="coms3.shootmessenger.ActivitySms"

        android:windowSoftInputMode="stateHidden" >


    </activity>

    <activity
        android:name="coms3.shootmessenger.ActivityBlackList"

        android:windowSoftInputMode="stateHidden" >
    </activity>

    <activity
        android:name="coms3.shootmessenger.ActivityDeleteMessage"

        android:windowSoftInputMode="stateHidden" >
    </activity>

    <activity
        android:name="coms3.shootmessenger.ActivityDeleteone"

        android:windowSoftInputMode="stateHidden" >
    </activity>

     <activity android:name="coms3.shootmessenger.ActivitySmsnew" >


      <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" />

        </intent-filter>


    </activity>

      <activity
        android:name="coms3.shootmessenger.ActivityEventlist"

        android:windowSoftInputMode="stateHidden" >
    </activity>

     <activity
        android:name="coms3.shootmessenger.ActivityScheduleList"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="stateHidden" >
    </activity>

      <activity
        android:name="coms3.shootmessenger.ActivityCancelSchedule"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="stateHidden" >
    </activity>

       <activity
        android:name="coms3.shootmessenger.ActivityCancelEvent"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="stateHidden" >
    </activity>

      <activity
        android:name="coms3.shootmessenger.ActivityCancelMail"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="stateHidden" >
    </activity>

   <activity
        android:name="coms3.shootmessenger.Activitytutorial"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="stateHidden" >
    </activity>

     <activity
        android:name="coms3.shootmessenger.ActivityConversationtutorial"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="stateHidden" >
    </activity>

    <activity
        android:name="coms3.shootmessenger.Aboutus"
        android:screenOrientation="portrait"
        android:windowSoftInputMode="stateHidden" >
    </activity>



     <service android:name="coms3.shootmessenger.HeadlessSmsSendService"
             android:permission="android.permission.SEND_RESPOND_VIA_MESSAGE"
             android:exported="true" >
        <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>




</application>

更新:

注意:我正在测试模拟器... 以下所有步骤后,我只看到了Android的默认消息应用程序不是我的一样如下图所示。任何形式的帮助将AP preciated。在此先感谢。

Note: I am testing on Emulator... After following all steps I only see the default messaging app of Android not mine like in the image given below. Any type of help will be appreciated. Thanks in Advance.

推荐答案

的instructions您发布是正确的 - 问题是,你必须实现所有的能力要求:

The instructions you posted were correct - the issue is that you must implement all of the required capabilities:

在一个广播接收器,包括一个意图过滤器 SMS_DELIVER_ACTION android.provider.Telephony.SMS_DELIVER )。该广播接收器还必须要求BROADCAST_SMS权限。 这使得你的应用程序直接接收收到的短信。

In a broadcast receiver, include an intent filter for SMS_DELIVER_ACTION ("android.provider.Telephony.SMS_DELIVER"). The broadcast receiver must also require the BROADCAST_SMS permission. This allows your app to directly receive incoming SMS messages.

在一个广播接收器,包括一个意图过滤器 WAP_PUSH_DELIVER_ACTION android.provider.Telephony.WAP_PUSH_DELIVER )与MIME类型应用程序/ vnd.wap.mms消息。该广播接收器还必须要求BROADCAST_WAP_PUSH权限。 这使得你的应用程序直接接收传入的彩信。

In a broadcast receiver, include an intent filter for WAP_PUSH_DELIVER_ACTION ("android.provider.Telephony.WAP_PUSH_DELIVER") with the MIME type "application/vnd.wap.mms-message". The broadcast receiver must also require the BROADCAST_WAP_PUSH permission. This allows your app to directly receive incoming MMS messages.

在你的活动,提供新信息,包括意图过滤器 ACTION_SENDTO android.intent.action.SENDTO )与架构,短信: smsto:彩信: mmsto:。 这使您的应用程序接收来自那些希望将邮件传递的其他应用程序的意图。

In your activity that delivers new messages, include an intent filter for ACTION_SENDTO ("android.intent.action.SENDTO") with schemas, sms:, smsto:, mms:, and mmsto:. This allows your app to receive intents from other apps that want to deliver a message.

在服务,包括意图过滤器 ACTION_RESPONSE_VIA_MESSAGE android.intent.action.RESPOND_VIA_MESSAGE )与架构,短信: smsto:彩信: mmsto:。该服务还必须要求 SEND_RESPOND_VIA_MESSAGE 许可。

In a service, include an intent filter for ACTION_RESPONSE_VIA_MESSAGE ("android.intent.action.RESPOND_VIA_MESSAGE") with schemas, sms:, smsto:, mms:, and mmsto:. This service must also require the SEND_RESPOND_VIA_MESSAGE permission.

如果没有所有四个,你的应用程序将不会被列在默认的SMS选择对话框。

Without all four, your app will not be listed in the default SMS selection dialog.