本文介绍了<使用-许可安卓名=" android.permission.SEND_SMS" />的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发表我的Play商店中的应用程序,但它不适用于平板电脑。我检查了谷歌Play商店应用程序的功能和一些研究之后发现,我的应用程序有一些电话功能,我相信这是有罪的一方。这是我的清单文件。

I published my application on Play Store but it is not available for tablets. I checked the functionality of the application on Google play store and after some research found that my application has some Telephony features which I believe is the guilty party. Here is my manifest file.

<uses-sdk
        android:minSdkVersion="7"
        android:targetSdkVersion="17" />

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE"></uses-permission>
    <uses-permission android:name="android.permission.CHANGE_WIFI_STATE"></uses-permission>
    <uses-permission android:name="android.permission.SEND_SMS" />

    <!-- GCM requires a Google account. -->
    <uses-permission android:name="android.permission.GET_ACCOUNTS" />

    <!-- Keeps the processor from sleeping when a message is received. -->
    <uses-permission android:name="android.permission.WAKE_LOCK" />

    <permission
        android:name=".permission.C2D_MESSAGE"
        android:protectionLevel="signature" />

    <uses-permission android:name=".permission.C2D_MESSAGE" />

    <!-- This app has permission to register and receive data message. -->
    <uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
    <!-- Keeps the device on vibrating mode when a message is received. -->
    <uses-permission android:name="android.permission.VIBRATE" />

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@android:style/Theme.Black.NoTitleBar" >

        <receiver
            android:name="com.google.android.gcm.GCMBroadcastReceiver"
            android:permission="com.google.android.c2dm.permission.SEND" >
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE" />
                <action android:name="com.google.android.c2dm.intent.REGISTRATION" />
                <category android:name="" />
            </intent-filter>
        </receiver>

        <service android:name=".GCMIntentService" />

        <activity
            android:name=".Splash"
            android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:name=".MainActivity"
            android:screenOrientation="portrait">
        </activity>

           <activity
            android:name=".SelectedArticlePush"
            android:screenOrientation="portrait">
        </activity>

        <activity
            android:name=".ActusScreen"
            android:screenOrientation="portrait">
        </activity>

          <activity
            android:name=".MentionLegale"
            android:screenOrientation="portrait">
        </activity>

        <activity
            android:name=".SelectedArticle"
            android:screenOrientation="portrait"
            android:windowSoftInputMode="stateAlwaysHidden|adjustPan">>
        </activity>

        <activity
            android:name=".ReglementScreen"
            android:screenOrientation="portrait">
        </activity>

        <activity
            android:name=".SelectedReglementation"
            android:screenOrientation="portrait">
        </activity>

        <activity
            android:name=".FavoriteScreen"
            android:screenOrientation="portrait">
        </activity>

        <activity
            android:name=".AlertScreen"
            android:screenOrientation="portrait">
        </activity>

        <activity
            android:name=".ClubScreen"
            android:screenOrientation="portrait">
        </activity>

         <activity
            android:name="ClubMi"
            android:screenOrientation="portrait">
        </activity>

        <activity
            android:name=".DisplayWeb"
            android:screenOrientation="portrait">
        </activity>

         <activity
            android:name=".Contact"
            android:screenOrientation="portrait">
        </activity>

         <activity
            android:name=".tab.TabClubMi"
            android:screenOrientation="portrait">
        </activity>

        <activity
            android:name=".SMS"
            android:screenOrientation="portrait"
            android:theme="@style/Theme.Transparent" >
        </activity>

    </application>

     <supports-screens
          android:largeScreens="true"
          android:normalScreens="true"
          android:smallScreens="true"
          android:resizeable="true"
          android:anyDensity="true" />

我相信&LT;使用-权限的Andr​​oid:名称=android.permission.SEND_SMS/&GT; 激活电话功能。不过,我需要这个权限发送短信。任何一个可以告诉我,如果有其它的方式,如果在平板电脑上运行被传递,例如:

I believe <uses-permission android:name="android.permission.SEND_SMS" /> activates the Telephony functionality. However I need this permission to send sms. Can any one tell me if there is an alternate way to by pass this if running in a Tablet.

推荐答案

添加应用,功能块的清单:

Add a uses-feature block to your Manifest:

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

以上告诉该功能用于在应用程序中的设备。该机器人:要求=假但是,确保这不是一个严格的要求,并安装应用程序,无论该设备配套的机器人。 hardware.telephony 功能。

The above tells the device that this feature is used in your application. The android:required="false" however, ensures that this is not a stringent requirement and will install the application regardless of the device supporting the android.hardware.telephony feature.

然而,这将创建一个新的问题的。担心不是。一个解决方案如下。 : - )

This however, creates a new problem. Worry not. A solution follows. :-)

在不支持 android.hardware.telephony 功能的设备会尝试使用该功能的任何方式,会发生什么?在你的情况,发送短信。一个简单的解决方法是,检查设备是否有使用电话功能的能力。

What happens when a device which does not support the android.hardware.telephony feature tries to use the function any way? In your case, sending out an SMS. A simple solution is, to check if the device has the capability to use the Telephony features.

TelephonyManager tm = (TelephonyManager) getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE);
if (tm.getPhoneType() == TelephonyManager.PHONE_TYPE_NONE)  {
    // SHOW A DIALOG, A TOAST OR A NOTIFICATION TO TELL THE USER THAT THE FEATURE IS MISSING
} else {
    // RUN THE CODE TO SEND OUT THE SMS
}

和我认为这是一种替代方法是正在运行的设备是CDMA设备。

And I think this is a workaround in case the device it is being run on is a CDMA device.

String strTM = ((TelephonyManager) getApplicationContext().getSystemService(Context.TELEPHONY_SERVICE)).getLine1Number();
if (strTM == null)  {
    // SHOW A DIALOG, A TOAST OR A NOTIFICATION TO TELL THE USER THAT THE FEATURE IS MISSING
} else {
    // RUN THE CODE TO SEND OUT THE SMS
}

无论是code以上的块,需要 READ_PHONE_STATE 的权限:

<uses-permission android:name="android.permission.READ_PHONE_STATE" />

有检查(使用 PackageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY))如果该设备具有上述特征的另一种方式。我个人从来没有得到解决,以测试它,但OP表示它的工作原理。 http://stackoverflow.com/a/6568243/450534

There is one more way of checking (using PackageManager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) if the device has the said features. I have personally never gotten around to test it, but the OP indicates it works. http://stackoverflow.com/a/6568243/450534

这篇关于&LT;使用-许可安卓名=&QUOT; android.permission.SEND_SMS&QUOT; /&GT;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-11 01:39